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


Python DrupyPHP.array_merge方法代码示例

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


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

示例1: drop_table

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import array_merge [as 别名]
def drop_table(ret, table):
  """
   Drop a table.
  
   @param ret
     Array to which query results will be added.
   @param table
     The table to be dropped.
  """
  php.Reference.check(ref)
  php.array_merge( update_sql('DROP TABLE {' +  table  + '}'), ret, True )
开发者ID:brendoncrawford,项目名称:drupy,代码行数:13,代码来源:database_mysqli.py

示例2: registry_cache_path_files

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import array_merge [as 别名]
def registry_cache_path_files():
    """
   Save the files required by the registry for this path.
  """
    used_code = registry_mark_code(None, None, True)
    if used_code:
        files = []
        type_sql = []
        params = []
        for type, names in used_code.items():
            type_sql.append("(name IN (" + db_placeholders(names, "varchar") + ") AND type = '%s')")
            params = php.array_merge(params, names)
            params.append(type)
        res = db_query("SELECT DISTINCT filename FROM {registry} WHERE " + php.implode(" OR ", type_sql), params)
        while True:
            row = db_fetch_object(res)
            if row == None:
                break
            files.append(row.filename)
        if files:
            sort(files)
            # Only write this to cache if the file list we are going to cache
            # is different to what we loaded earlier in the request.
            if files != registry_load_path_files(True):
                menu = menu_get_item()
                cache_set("registry:" + menu["path"], php.implode(";", files), "cache_registry")
开发者ID:sabren,项目名称:drupy,代码行数:28,代码来源:bootstrap.py

示例3: scan_directory

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import array_merge [as 别名]
def scan_directory(dir, mask, nomask = ['.', '..', 'CVS'], \
    callback = 0, recurse = True, key = 'filename', min_depth = 0, depth = 0):
  """
   Finds all files that match a given mask in a given directory.
   Directories and files beginning with a period are excluded; this
   prevents hidden files and directories (such as SVN working directories)
   from being scanned.
  
   @param dir
     The base directory for the scan, without trailing slash.
   @param mask
     The regular expression of the files to find.
   @param nomask
     An array of files/directories to ignore.
   @param callback
     The callback function to call for each match.
   @param recurse
     When True, the directory scan will recurse the entire tree
     starting at the provided directory.
   @param key
     The key to be used for the returned array of files + Possible
     values are "filename", for the path starting with dir,
     "basename", for the basename of the file, and "name" for the name
     of the file without an extension.
   @param min_depth
     Minimum depth of directories to return files from.
   @param depth
     Current depth of recursion + This parameter is only used
     internally and should not be passed.
  
   @return
     An associative array (keyed on the provided key) of objects with
     "path", "basename", and "name" members corresponding to the
     matching files.
  """
  key = (key if php.in_array(key, \
    ('filename', 'basename', 'name')) else 'filename')
  files = []
  if php.is_dir(dir):
    dir_files = php.scandir(dir)
    for file in dir_files:
      if (not php.in_array(file, nomask) and file[0] != '.'):
        if (php.is_dir("%s/%s" % (dir, file)) and recurse):
          # Give priority to files in this folder by
          # merging them in after any subdirectory files.
          files = php.array_merge(file_scan_directory("%s/%s" % (dir, file), \
            mask, nomask, callback, recurse, key, min_depth, depth + 1), files)
        elif (depth >= min_depth and ereg(mask, file)):
          # Always use this match over anything already
          # set in files with the same $key.
          filename = "%s/%s" % (dir, file)
          basename_ = php.basename(file)
          name = php.substr(basename_, 0, php.strrpos(basename_, '.'))
          files[key] = php.stdClass()
          files[key].filename = filename
          files[key].basename = basename_
          files[key].name = name
          if (callback):
            callback(filename)
  return files
开发者ID:brendoncrawford,项目名称:drupy,代码行数:62,代码来源:file.py

示例4: get_querystring

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import array_merge [as 别名]
def get_querystring():
  """
   Compose a query string to append to table sorting requests.

   @return
     A query string that consists of all components of the current page request
     except for those pertaining to table sorting.
  """
  return lib_common.drupal_query_string_encode(
    _REQUEST, php.array_merge(['q', 'sort', 'order'], php.array_keys(_COOKIE)))
开发者ID:brendoncrawford,项目名称:drupy,代码行数:12,代码来源:tablesort.py

示例5: drupal_get_schema

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import array_merge [as 别名]
def drupal_get_schema(table=None, rebuild=False):
    """
   Get the schema definition of a table, or the whole database schema.
  
   The returned schema will include any modifications made by any
   module that implements hook_schema_alter().
  
   @param $table
     The name of the table. If not given, the schema of all tables is returned.
   @param $rebuild
     If true, the schema will be rebuilt instead of retrieved from the cache.
  """
    php.static(drupal_get_schema, "schema", [])
    if php.empty(drupal_get_schema.schema) or rebuild:
        # Try to load the schema from cache.
        cached = lib_cache.get("schema")
        if not rebuild and cached:
            drupal_get_schema.schema = cached.data
        # Otherwise, rebuild the schema cache.
        else:
            drupal_get_schema.schema = []
            # Load the .install files to get hook_schema.
            # On some databases this function may be called before bootstrap has
            # been completed, so we force the functions we need to load just in case.
            if drupal_function_exists("module_load_all_includes"):
                # There is currently a bug in module_list() where it caches what it
                # was last called with, which is not always what you want.
                # module_load_all_includes() calls module_list(), but if this function
                # is called very early in the bootstrap process then it will be
                # uninitialized and therefore return no modules.  Instead, we have to
                # "prime" module_list() here to to values we want, specifically
                # "yes rebuild the list and don't limit to bootstrap".
                # TODO: Remove this call after http://drupal.org/node/222109 is fixed.
                lib_plugin.list(True, False)
                lib_plugin.load_all_includes("install")
            # Invoke hook_schema for all modules.
            for module in module_implements("schema"):
                current = lib_plugin.invoke(module, "schema")
                if drupal_function_exists("_drupal_initialize_schema"):
                    _drupal_initialize_schema(module, current)
                schema = php.array_merge(schema, current)
            if drupal_function_exists("drupal_alter"):
                drupal_alter("schema", schema)
            if drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL:
                cache_set("schema", schema)
    if table is None:
        return schema
    elif php.isset(schema, table):
        return schema[table]
    else:
        return False
开发者ID:sabren,项目名称:drupy,代码行数:53,代码来源:bootstrap.py

示例6: save_upload

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import array_merge [as 别名]
def save_upload(source, validators = {}, dest = False, \
    replace = FILE_EXISTS_RENAME):
  """
   Saves a file upload to a new location + The source file is validated as a
   proper upload and handled as such.
  
   The file will be added to the files table as a temporary file.
   Temporary files
   are periodically cleaned + To make the file permanent file call
   file_set_status() to change its status.
  
   @param source
     A string specifying the name of the upload field to save.
   @param validators
     An optional, associative array of callback functions used to validate the
     file + The keys are function names and the values arrays of callback
     parameters which will be passed in after the user and file objects + The
     functions should return an array of error messages, an empty array
     indicates that the file passed validation.
     The functions will be called in
     the order specified.
   @param dest
     A string containing the directory source should be copied to + If this is
     not provided or is not writable, the temporary directory will be used.
   @param replace
     A boolean indicating whether an existing file of the same name in the
     destination directory should overwritten + A False value will generate a
     new, unique filename in the destination directory.
   @return
     An object containing the file information, or False
     in the event of an error.
  """
  php.static(file_save_upload, 'upload_cache', {})
  # Add in our check of the the file name length.
  validators['file_validate_name_length'] = {}
  # Return cached objects without processing since the file will have
  # already been processed and the paths in FILES will be invalid.
  if (php.isset(file_save_upload.uploadcache, source)):
    return file_save_upload.uploadcache[source]
  # If a file was uploaded, process it.
  if (php.isset(p.FILES, 'files') and p.FILES['files']['name'][source] and \
      php.is_uploaded_file(p.FILES['files']['tmp_name'][source])):
    # Check for file upload errors and return False if a
    # lower level system error occurred.
    # @see http://php.net/manual/en/features.file-upload.errors.php
    if p.FILES['files']['error'][source] == UPLOAD_ERR_OK:
      pass
    elif p.FILES['files']['error'][source] == UPLOAD_ERR_INI_SIZE or \
        p.FILES['files']['error'][source] == UPLOAD_ERR_FORM_SIZE:
      drupal_set_message(t(\
        'The file %file could not be saved, because it exceeds %maxsize, ' + \
        'the maximum allowed size for uploads.', \
        {'%file' : source, '%maxsize' : \
        format_size(file_upload_max_size())}), 'error')
      return False
    elif p.FILES['files']['error'][source] == UPLOAD_ERR_PARTIAL or \
        p.FILES['files']['error'][source] == UPLOAD_ERR_NO_FILE:
      drupal_set_message(t('The file %file could not be saved, ' + \
        'because the upload did not complete.', {'%file' : source}), 'error')
      return False
    # Unknown error
    else:
      drupal_set_message(t('The file %file could not be saved. ' + \
        'An unknown error has occurred.', {'%file' : source}), 'error')
      return False
    # Build the list of non-munged extensions.
    # @todo: this should not be here + we need to figure out the right place.
    extensions = ''
    for rid,name in lib_appglobals.user.roles.items():
      extensions += ' ' + variable_get("upload_extensions_rid",
      variable_get('upload_extensions_default', \
        'jpg jpeg gif png txt html doc xls pdf ppt pps odt ods odp'))
    # Begin building file object.
    file = php.stdClass()
    file.filename = file_munge_filename(php.trim(\
      basename(p.FILES['files']['name'][source]), '.'), extensions)
    file.filepath = p.FILES['files']['tmp_name'][source]
    file.filemime = p.FILES['files']['type'][source]
    # Rename potentially executable files, to help prevent exploits.
    if (php.preg_match('/\.(php|pl|py|cgi|asp|js)$/i', file.filename) and \
        (php.substr(file.filename, -4) != '.txt')):
      file.filemime = 'text/plain'
      file.filepath += '.txt'
      file.filename += '.txt'
    # If the destination is not provided, or is not writable, then use the
    # temporary directory.
    if (php.empty(dest) or file_check_path(dest) == False):
      dest = file_directory_temp()
    file.source = source
    file.destination = file_destination(file_create_path(dest + '/' + \
      file.filename), replace)
    file.filesize = FILES['files']['size'][source]
    # Call the validation functions.
    errors = {}
    for function,args in validators.items():
      array_unshift(args, file)
      errors = php.array_merge(errors, function(*args))
    # Check for validation errors.
    if (not php.empty(errors)):
      message = t('The selected file %name could not be uploaded.', \
#.........这里部分代码省略.........
开发者ID:brendoncrawford,项目名称:drupy,代码行数:103,代码来源:file.py


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