当前位置: 首页>>代码示例>>Python>>正文


Python DrupyPHP.preg_quote方法代码示例

本文整理汇总了Python中lib.drupy.DrupyPHP.preg_quote方法的典型用法代码示例。如果您正苦于以下问题:Python DrupyPHP.preg_quote方法的具体用法?Python DrupyPHP.preg_quote怎么用?Python DrupyPHP.preg_quote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.drupy.DrupyPHP的用法示例。


在下文中一共展示了DrupyPHP.preg_quote方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: drupal_match_path

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import preg_quote [as 别名]
def drupal_match_path(path_, patterns):
  """
   Check if a path matches any pattern in a set of patterns.
  
   @note DRUPY:
     This function was substantially modified
   @param path
     The path to match.
   @param patterns
     String containing a set of patterns separated by \n, \r or \r\n.  
   @return
     Boolean value: TRUE if the path matches a pattern, FALSE otherwise.
  """
  php.static(drupal_match_path, 'regexps')
  if (not php.isset(drupal_match_path.regexps, patterns)):
    frnt = variable_get('site_frontpage', 'node');
    frnt_q = php.preg_quote(frnt, '/');
    frnt_p = '\1' + frnt_q + '\2';
    pra2 = ['|', '.*', frnt_p];
    pra1 = ['/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'];
    pat_q = php.preg_quote(patterns, '/');
    pat_prep = php.preg_replace(pra1, pra2, pat_q);
    pat_final = '/^(' + pat_prep + ')$/';
    drupal_match_path.regexps[patterns] = pat_final;
    return (php.preg_match(drupal_match_path.regexps[patterns], path_) > 0)
  else:
    return False
开发者ID:brendoncrawford,项目名称:drupy,代码行数:29,代码来源:path.py

示例2: validate_extensions

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import preg_quote [as 别名]
def validate_extensions(file, extensions):
  """
   Check that the filename ends with an allowed extension + This check is not
   enforced for the user #1.
  
   @param file
     A Drupal file object.
   @param extensions
     A string with a space separated
   @return
     An array + If the file extension is not allowed,
     it will contain an error message.
  """
  errors = []
  # Bypass validation for uid  = 1.
  if (lib_appglobals.user.uid != 1):
    regex = '/\.(' + ereg_replace(' +', '|', \
      php.preg_quote(extensions)) + ')$/i'
    if (not php.preg_match(regex, file.filename)):
      errors.append( t('Only files with the following extensions ' + \
        'are allowed: %files-allowed.', {'%files-allowed' : extensions}) )
  return errors
开发者ID:brendoncrawford,项目名称:drupy,代码行数:24,代码来源:file.py


注:本文中的lib.drupy.DrupyPHP.preg_quote方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。