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


Python DrupyPHP.preg_replace_callback方法代码示例

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


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

示例1: mime_header_decode

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import preg_replace_callback [as 别名]
def mime_header_decode(header_):
  """
   Complement to mime_header_encode
  """
  # First step: encoded chunks followed by
  # other encoded chunks (need to collapse whitespace)
  header_ = php.preg_replace_callback(\
    '/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=\s+(?==\?)/', \
    '_mime_header_decode', header_);
  # Second step: remaining chunks (do not collapse whitespace)
  return php.preg_replace_callback(\
    '/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=/', '_mime_header_decode', header_);
开发者ID:brendoncrawford,项目名称:drupy,代码行数:14,代码来源:unicode.py

示例2: drupal_strtoupper

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import preg_replace_callback [as 别名]
def drupal_strtoupper(text):
  """
   Uppercase a UTF-8 string.
  """
  if (lib_appglobals.multibyte == UNICODE_MULTIBYTE):
    return php.mb_strtoupper(text);
  else:
    # Use C-locale for ASCII-only uppercase
    text = php.strtoupper(text);
    # Case flip Latin-1 accented letters
    text = php.preg_replace_callback('/\xC3[\xA0-\xB6\xB8-\xBE]/', \
      _unicode_caseflip, text);
    return text;
开发者ID:brendoncrawford,项目名称:drupy,代码行数:15,代码来源:unicode.py

示例3: query_temporary

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import preg_replace_callback [as 别名]
def query_temporary(query):
  """
   Runs a SELECT query and stores its results in a temporary table.
  
   Use this as a substitute for db_query() when the results need to stored
   in a temporary table. Temporary tables exist for the duration of the page
   request.
   User-supplied arguments to the query should be passed in as
   separate parameters
   so that they can be properly escaped to avoid SQL injection attacks.
  
   Note that if you need to know how many results were returned, you should do
   a SELECT COUNT(*) on the temporary table afterwards. db_affected_rows() does
   not give consistent result across different database types in this case.
  
   @param query
     A string containing a normal SELECT SQL query.
   @param ...
     A variable number of arguments which are substituted into the query
     using printf() syntax. The query arguments can be enclosed in one
     array instead.
     Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
     in '') and %%.
  
     NOTE: using this syntax will cast None and False values to decimal 0,
     and True values to decimal 1.
  
   @param table
     The name of the temporary table to select into. This name will not be
     prefixed as there is no risk of collision.
   @return
     A database query result resource, or False if the query was not executed
     correctly.
  """
  args = func_get_args()
  tablename = php.array_pop(args)
  php.array_shift(args)
  query = php.preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE ' +  \
    tablename  + ' Engine=HEAP SELECT', db_prefix_tables(query))
  # 'All arguments in one array' syntax
  if (php.isset(args, 0) and php.is_array(args, 0)): 
    args = args[0]
  _db_query_callback(args, True)
  query = php.preg_replace_callback(DB_QUERY_REGEXP, \
    '_db_query_callback', query)
  return _db_query(query)
开发者ID:brendoncrawford,项目名称:drupy,代码行数:48,代码来源:database_mysqli.py

示例4: query_range

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import preg_replace_callback [as 别名]
def query_range(query):
  """
   Runs a limited-range query in the active database.
  
   Use this as a substitute for db_query() when a subset of the query is to be
   returned. User-supplied arguments to the query should be passed in as
   separate parameters so that they can be properly escaped to avoid SQL
   injection attacks.
  
   @param query
     A string containing an SQL query.
   @param ...
     A variable number of arguments which are substituted into the query
     using printf() syntax. The query arguments can be enclosed in one
     array instead.
     Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
     in '') and %%.
     NOTE: using this syntax will cast None and False values to decimal 0,
     and True values to decimal 1.
   @param from
     The first result row to return.
   @param count
     The maximum number of result rows to return.
   @return
     A database query result resource, or False if the query was not executed
     correctly.
  """
  args = func_get_args()
  count = php.array_pop(args)
  from_ = php.array_pop(args)
  php.array_shift(args)
  query = db_prefix_tables(query)
  # 'All arguments in one array' syntax
  if (php.isset(args, 0) and php.is_array(args, 0)): 
    args = args[0]
  _db_query_callback(args, True)
  query = php.preg_replace_callback(DB_QUERY_REGEXP, \
    '_db_query_callback', query)
  query += ' LIMIT ' +  int(from_)  + ', ' . int(count)
  return _db_query(query)
开发者ID:brendoncrawford,项目名称:drupy,代码行数:42,代码来源:database_mysqli.py

示例5: query

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import preg_replace_callback [as 别名]
def query(query_, *args):
  """
   Runs a basic query in the active database.
  
   User-supplied arguments to the query should be passed in as separate
   parameters so that they can be properly escaped to avoid SQL injection
   attacks.
  
   @param query
     A string containing an SQL query.
   @param ...
     A variable number of arguments which are substituted into the query
     using printf() syntax. Instead of a variable number of query arguments,
     you may also pass a single array containing the query arguments.
  
     Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose
     in '') and %%.
  
     NOTE: using this syntax will cast None and False values to decimal 0,
    and True values to decimal 1.
  
   @return
     A database query result resource, or False if the query was not
     executed correctly.
  """
  this_query = lib_database.prefix_tables(query_)
  # 'All arguments in one array' syntax
  if (php.isset(args, 0) and php.is_array(args[0])): 
    args = args[0]
  lib_database._query_callback(args, True)
  this_query = php.preg_replace_callback(lib_database.DB_QUERY_REGEXP, \
    lib_database._query_callback, this_query)
  #print
  #print "QUERY DEBUG:"
  #print this_query
  #print
  return _query(this_query)
开发者ID:brendoncrawford,项目名称:drupy,代码行数:39,代码来源:database_mysqli.py


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