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


Python string.splitfields函数代码示例

本文整理汇总了Python中string.splitfields函数的典型用法代码示例。如果您正苦于以下问题:Python splitfields函数的具体用法?Python splitfields怎么用?Python splitfields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: getScaleFromRaster

def getScaleFromRaster(inputRaster, gp):
    ## Automatic Image Scale Calculation (if possible)
    ## The method used in the original Avenue script:
    ## 1. Get the extent of the Image. (This would be in Geographic Decimal Degrees) (theExtent) 
    ## 2. Get the Number of Columns of the image (theCols) 
    ## 3. Divide the Number of Columns / The Width of the image. (This would give Pixels per DD) {theRes = theCols / theExtent.GetWidth} 
    ## 4. Get the approximate # of pixels per meter by dividing {theScale = 111120/theRes } 
    ## 5. Then logic was applied to guess to populate the scale value in the MA Catalog. 
    ## If theScale <= 5
    ## Then 
    ##     theScale = theScale.Round & "M"
    ## Else 
    ##      theScale = theScale * 5000
    ## If (theScale >= 1000000) Then 
    ##      theScale = "1:" + (theScale/1000000).Round & "M"  df
    defaultScale = 50001
    minPossibleScale = 100 # assumes image will never be smaller than 100m
    maxPossibleScale = 40000000 # the circumference of the earth in meters

    try:

        if not IsGeographicSR(inputRaster, gp) : 
            msgNotWGS84 = msgDatasetNotGeographicUsingDefaultScale + str(defaultScale)
            raise Exception, msgNotWGS84
                
        description = gp.describe(inputRaster)
                
        if debug : gp.AddMessage("Extent = " + description.Extent)

        minX = float(string.splitfields(description.Extent," ")[0])
        maxX = float(string.splitfields(description.Extent," ")[2])
        widthDecDegrees = abs(maxX - minX)
        
        if debug : gp.AddMessage("Width (Decimal Degrees) = " + str(widthDecDegrees))

        pixelsPerDecDegrees = description.Width / widthDecDegrees            
        if debug : gp.AddMessage("Pixels per Decimal Degrees = " + str(pixelsPerDecDegrees))

        pixelsPerMeter = 111120 / pixelsPerDecDegrees           
        if debug : gp.AddMessage("Pixels per Meter = " + str(pixelsPerMeter))

        theScale = round(pixelsPerMeter * 5000.0)
        
        if (pixelsPerMeter < 5) : theScale = round(pixelsPerMeter)                
        if debug : gp.AddMessage("Calculated Scale = " + str(theScale))

        nScale = long(theScale)

        # check the calculated scale for bogus values
        if (nScale < minPossibleScale) or (nScale > maxPossibleScale) :
            raise Exception, msgCalculatedScaleIsOutOfBounds                

        return nScale
    
    except Exception, ErrorDesc:
        # Except block if automatic scale calculation can not be performed
        # Just return the default Scale
        gp.AddWarning(msgCouldNotCalculateScale + str(defaultScale) + " Image=" + inputRaster);
        gp.AddWarning(str(ErrorDesc))                
        return defaultScale
开发者ID:mfunk,项目名称:MA-Storage,代码行数:60,代码来源:NonRPFRasterLoader.py

示例2: get_menu_left_from_sections

def get_menu_left_from_sections(item_container, name, sections, url=None):
    if url == None:
      url = item_container.get_absolute_url()
    if name != '':
      url = url.replace('index.html', '') + name + '/index.html'
    s_name = 'Start'
    s_info = 'Startseite'
    text = u'0 | %s | %s | %s | %s | <b><i><span class="red">::</span></i></b>\n999\n' % \
           (s_name.lower(), url, s_name, s_info)
    objs = string.splitfields(sections, '\n')
    for obj in objs:
      obj = obj.strip()
      if obj != '':
        arr = string.splitfields(obj, '|')
        m_name = arr[0].strip()
        if len(arr) == 1:
          arr.append(m_name.lower())
          f_name = check_name(arr[1].strip(), True)
        else:
          f_name = arr[1].strip()
        n_pos = f_name.find('/')
        if n_pos > 0:
          menu = f_name[:n_pos]
        else:
          menu = f_name
        s_name = obj.strip()
        text += u'1 | %s | %s%s/index.html | %s\n' % \
                ( menu, url.replace('index.html', ''), f_name, m_name)
    return text
开发者ID:shagun30,项目名称:djambala-2,代码行数:29,代码来源:utils.py

示例3: get_navmenu_choices_left

def get_navmenu_choices_left(menu_id):
  """ Auswahl des Navigationsmenus """
  ret = []
  ret.append( ('|', mark_safe(_('<b><i>(Lokale) Startseite</i></b>'))) )
  menu = get_menuitems_by_menu_id_left(menu_id)[0]
  lines = string.splitfields(menu.navigation, '\n')
  nav_main = ''
  nav_sub = ''
  for line in lines:
    line = string.strip(line)
    if line != '' and line[0] != '#':
      arr = string.splitfields(line, '|')
      if len(arr) > 1:
        my_depth = int(string.strip(arr[0]))
        my_alias = string.strip(arr[1])
        if my_depth == 0:
          nav_main = my_alias
          nav_sub = ''
        else:
          nav_sub = my_alias
        info = string.strip(arr[3])
        if my_depth == 0:
          info = '<b>' + info + '</b>'
        ret.append( (nav_main + '|' + nav_sub, mark_safe(info)) )
  return ret
开发者ID:shagun30,项目名称:djambala-2,代码行数:25,代码来源:utils_navigation.py

示例4: DomConvert

def DomConvert(node, xslParent, xslDoc, extUris, extElements, preserveSpace):
    if node.nodeType == Node.ELEMENT_NODE:
        mapping = g_mappings.get(node.namespaceURI, None)
        if mapping:
            if not mapping.has_key(node.localName):
                raise XsltException(Error.XSLT_ILLEGAL_ELEMENT, node.localName)
            xsl_class = mapping[node.localName]

            xsl_instance = xsl_class(xslDoc, baseUri=xslParent.baseUri)
            for attr in node.attributes.values():
                if not attr.namespaceURI and attr.localName not in xsl_instance.__class__.legalAttrs:
                    raise XsltException(Error.XSLT_ILLEGAL_ATTR,
                                        attr.nodeName, xsl_instance.nodeName)
                xsl_instance.setAttributeNS(attr.namespaceURI, attr.nodeName,
                                            attr.value)
            xslParent.appendChild(xsl_instance)
        elif node.namespaceURI in extUris:
            name = (node.namespaceURI, node.localName)
            if name in extElements.keys():
                ext_class = extElements[name]
            else:
                #Default XsltElement behavior effects fallback
                ext_class = XsltElement
            xsl_instance = ext_class(xslDoc, node.namespaceURI,
                                     node.localName, node.prefix,
                                     xslParent.baseUri)
            for attr in node.attributes.values():
                if (attr.namespaceURI, attr.localName) == (XSL_NAMESPACE, 'extension-element-prefixes'):
                    ext_prefixes = string.splitfields(attr.value)
                    for prefix in ext_prefixes:
                        if prefix == '#default': prefix = ''
                        extUris.append(node_nss[prefix])
                xsl_instance.setAttributeNS(attr.namespaceURI, attr.nodeName,
                                            attr.value)
            xslParent.appendChild(xsl_instance)
        else:
            xsl_instance = LiteralElement(xslDoc, node.namespaceURI,
                                          node.localName, node.prefix,
                                          xslParent.baseUri)
            node_nss = GetAllNs(node)
            for attr in node.attributes.values():
                if (attr.namespaceURI, attr.localName) == (XSL_NAMESPACE, 'extension-element-prefixes'):
                    ext_prefixes = string.splitfields(attr.value)
                    for prefix in ext_prefixes:
                        if prefix == '#default': prefix = ''
                        extUris.append(node_nss[prefix])
                xsl_instance.setAttributeNS(attr.namespaceURI,
                                            attr.nodeName,
                                            attr.value
                                            )
            xslParent.appendChild(xsl_instance)
        ps = (xsl_instance.namespaceURI, xsl_instance.localName) == (XSL_NAMESPACE, 'text') or xsl_instance.getAttributeNS(XML_NAMESPACE,'space') == 'preserve'
        #ps = (xsl_instance.namespaceURI, xsl_instance.localName) == (XSL_NAMESPACE, 'text')
        for child in node.childNodes:
            DomConvert(child, xsl_instance, xslDoc, extUris, extElements, ps)
    elif node.nodeType == Node.TEXT_NODE:
        if string.strip(node.data) or preserveSpace:
            xsl_instance = LiteralText(xslDoc, node.data)
            xslParent.appendChild(xsl_instance)
    return
开发者ID:Birdbird,项目名称:StartPage,代码行数:60,代码来源:StylesheetReader.py

示例5: create_members

def create_members(org_id, group_id, target_group_ids, fcontent):
  """ legt mehrere User fuer org_id an und ordnet sie der group_id zu """
  lines = string.splitfields(fcontent)
  for line in lines:
    if line.find('@') > 0:
      line = line.replace('"', '')
      items = string.splitfields(line.strip(), ';')
      if len(items) == 4:
        sex = items[0].strip()
        first_name = items[1].strip()
        last_name = items[2].strip()
        email = items[3].strip()
        title = ''
      elif len(items) == 5:
        sex = items[0].strip()
        title = items[1].strip()
        first_name = items[2].strip()
        last_name = items[3].strip()
        email = items[4].strip()
      elif len(items) == 6:
        sex = items[1].strip()
        title = items[2].strip()
        first_name = items[3].strip()
        last_name = items[4].strip()
        email = items[5].strip()
      create_member(org_id, group_id, target_group_ids, sex, first_name, last_name, title_name, email)
开发者ID:shagun30,项目名称:djambala-2,代码行数:26,代码来源:views_group_insert_user.py

示例6: get_german_date

def get_german_date(d):
  """ d=2003-02-01 10:11:12 -> 01.02.2003 10:11"""
  arr = string.splitfields(d, ' ')
  Y, M, D = string.splitfields(arr[0], '-')
  h, m, s = string.splitfields(arr[1], ':')
  dt = datetime.datetime(int(Y),int(M),int(D),int(h),int(m))
  return dt.strftime('%d.%m.%Y %H:%M')
开发者ID:shagun30,项目名称:djambala-2,代码行数:7,代码来源:utils.py

示例7: parse_qs

def parse_qs(qs, keep_blank_values=None):
    """Parse a query given as a string argumen

        Arguments:

	qs              : URL-encoded query string to be parsed

        keep_blank_values: flag indicating whether blank values in
            URL encoded queries should be treated as blank strings.  
            A true value inicates that blanks should be retained as 
            blank strings.  The default false value indicates that
	    blank values are to be ignored and treated as if they were
	    not included.
    """
    import urllib, regsub
    name_value_pairs = string.splitfields(qs, '&')
    dict = {}
    for name_value in name_value_pairs:
	nv = string.splitfields(name_value, '=')
	if len(nv) != 2:
	    continue
	name = nv[0]
	value = urllib.unquote(regsub.gsub('+', ' ', nv[1]))
        if len(value) or keep_blank_values:
	    if dict.has_key (name):
		dict[name].append(value)
	    else:
		dict[name] = [value]
    return dict
开发者ID:asottile,项目名称:ancient-pythons,代码行数:29,代码来源:cgi.py

示例8: parse_qsl

def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
    """Parse a query given as a string argument.

        Arguments:

        qs: URL-encoded query string to be parsed

        keep_blank_values: flag indicating whether blank values in
            URL encoded queries should be treated as blank strings.  
            A true value inicates that blanks should be retained as 
            blank strings.  The default false value indicates that
            blank values are to be ignored and treated as if they were
            not included.

        strict_parsing: flag indicating what to do with parsing errors.
            If false (the default), errors are silently ignored.
            If true, errors raise a ValueError exception.

       Returns a list, as God intended.
    """
    name_value_pairs = string.splitfields(qs, '&')
    r=[]
    for name_value in name_value_pairs:
        nv = string.splitfields(name_value, '=')
        if len(nv) != 2:
            if strict_parsing:
                raise ValueError, "bad query field: %s" % `name_value`
            continue
        name = urllib.unquote(string.replace(nv[0], '+', ' '))
        value = urllib.unquote(string.replace(nv[1], '+', ' '))
        r.append((name, value))

    return r
开发者ID:MinasAbrahamyan,项目名称:bobomail,代码行数:33,代码来源:cgi.py

示例9: read_input

    def read_input(self,inputfile):
        # 1. read user input file
        for line in open(inputfile,'r').readlines():

            # Remove leading and trailing whitespace from line
            line = string.strip(line)

            # Skip blank lines
            if len(line) > 0 and line[0] != '#':
                x = string.splitfields(line,'=')
                y = string.splitfields(x[1],'#')
                arg = string.strip(x[0])
                val = string.strip(y[0])

                self.user_dict[arg] = val

        # 2. build complete input file, looking for errors
        for x in self.user_dict.keys():
            if self.data_dict.has_key(x) == 1:
                self.data_dict[x] = self.user_dict[x]
            elif self.dep_dict.has_key(x) == 1:
                self.error=1
                self.error_msg=self.error_msg+'JAAM ERROR: Deprecated parameter '+x+'\n'
                self.error_msg=self.error_msg+'       '+self.dep_dict[x]+'\n'
            else:
                self.error=1
                self.error_msg=self.error_msg+"JAAM ERROR: Bogus parameter "+x+'\n'

        if self.error == 0:
            f=open(inputfile+self.extension,'w')
            for x in self.data_orderlist:
                f.write(self.data_dict[x]+'  '+x+'\n')
开发者ID:jcandy,项目名称:jaam,代码行数:32,代码来源:jaaminput.py

示例10: save_menus_top

def save_menus_top(menu_id, text, profi_mode=False):
  """ speichert das obere Hauptmenu """

  def save_this_menu (menu_id, name, navigation):
    item = get_new_navmenu_top()
    item.menu_id = menu_id
    item.name = name
    item.navigation = navigation
    item.save()

  #if not profi_mode:
  #  text = decode_html(text)
  lines = string.splitfields(text, '\n')

  delete_menuitem_navmenu_top(menu_id)
  menu = get_top_navigation_menu_top(lines, profi_mode)
  save_this_menu(menu_id, '|', menu)

  nav_main = ''
  for line in lines:
    line = string.strip(line)
    if line != '' and line[0] != '#':
      arr = string.splitfields(line, '|')
      if len(arr) > 1:
        my_alias = string.strip(arr[0])
        nav_main = my_alias
        info = string.strip(arr[3])
        menu = get_top_navigation_menu(lines, nav_main, profi_mode)
        save_this_menu(menu_id, nav_main, menu)
开发者ID:shagun30,项目名称:djambala-2,代码行数:29,代码来源:utils_navigation.py

示例11: pathname2url

def pathname2url(p):

	""" Convert a DOS path name to a file url...
	Currently only works for absolute paths

		C:\foo\bar\spam.foo

			becomes

		///C|/foo/bar/spam.foo
	"""

	import string
	comp = string.splitfields(p, ':')
	if len(comp) != 2 or len(comp[0]) > 1:
		error = 'Bad path: ' + p
		raise IOError, error

	drive = string.upper(comp[0])
	components = string.splitfields(comp[1], '\\')
	path = '///' + drive + '|'
	for comp in components:
		if comp:
			path = path + '/' + comp
	return path
开发者ID:asottile,项目名称:ancient-pythons,代码行数:25,代码来源:nturl2path.py

示例12: normpath

def normpath(path):
	path = normcase(path)
	prefix, path = splitdrive(path)
	while path[:1] == os.sep:
		prefix = prefix + os.sep
		path = path[1:]
	comps = string.splitfields(path, os.sep)
	i = 0
	while i < len(comps):
		if comps[i] == '.':
			del comps[i]
		elif comps[i] == '..' and i > 0 and \
					  comps[i-1] not in ('', '..'):
			del comps[i-1:i+1]
			i = i-1
		elif comps[i] == '' and i > 0 and comps[i-1] <> '':
			del comps[i]
		elif '.' in comps[i]:
			comp = string.splitfields(comps[i], '.')
			comps[i] = comp[0][:8] + '.' + comp[1][:3]
			i = i+1
		elif len(comps[i]) > 8:
			comps[i] = comps[i][:8]
			i = i+1
		else:
			i = i+1
	# If the path is now empty, substitute '.'
	if not prefix and not comps:
		comps.append('.')
	return prefix + string.joinfields(comps, os.sep)
开发者ID:asottile,项目名称:ancient-pythons,代码行数:30,代码来源:dospath.py

示例13: listar_dependencias

def listar_dependencias(seccion):
    dependencias = {}
    dependencias["simples"] = []
    dependencias["comp"] = []
    if seccion == None or seccion.get('Depends') == None:
        return dependencias
    else:
        deps = string.splitfields(seccion.get('Depends'), ", ")
        for d in deps:
            if re.findall("\|", d):
                lista_or_raw = string.splitfields(d, " | ")
                tmpls = []
                for i in lista_or_raw:
                    if re.findall("\s", i):
                        obj = string.splitfields(i, " ", 1)
                        sp = dependencia_simple(obj[0], obj[1])
                        tmpls.append(sp)
                    else:
                        obj = string.splitfields(i, " ", 1)
                        sp = dependencia_simple(obj[0])
                        tmpls.append(sp)
                dependencias["comp"].append(tmpls)
            
            elif re.findall("\s", d):                
                obj = string.splitfields(d, " ", 1)
                sp = dependencia_simple(obj[0], obj[1])
                dependencias["simples"].append(sp)
            else:
                sp = dependencia_simple(d)
                dependencias["simples"].append(sp)
        return dependencias
开发者ID:Nitri0,项目名称:pruebasTribus,代码行数:31,代码来源:ingresardatos.py

示例14: normpath

def normpath(path):
    """Normalize a path, e.g. A//B, A/./B and A/foo/../B all become A/B.
    Also, components of the path are silently truncated to 8+3 notation."""

    path = string.replace(path, "/", "\\")
    prefix, path = splitdrive(path)
    while path[:1] == os.sep:
        prefix = prefix + os.sep
        path = path[1:]
    comps = string.splitfields(path, os.sep)
    i = 0
    while i < len(comps):
        if comps[i] == '.':
            del comps[i]
        elif comps[i] == '..' and i > 0 and \
                      comps[i-1] not in ('', '..'):
            del comps[i-1:i+1]
            i = i-1
        elif comps[i] == '' and i > 0 and comps[i-1] <> '':
            del comps[i]
        elif '.' in comps[i]:
            comp = string.splitfields(comps[i], '.')
            comps[i] = comp[0][:8] + '.' + comp[1][:3]
            i = i+1
        elif len(comps[i]) > 8:
            comps[i] = comps[i][:8]
            i = i+1
        else:
            i = i+1
    # If the path is now empty, substitute '.'
    if not prefix and not comps:
        comps.append('.')
    return prefix + string.joinfields(comps, os.sep)
开发者ID:asottile,项目名称:ancient-pythons,代码行数:33,代码来源:dospath.py

示例15: get_points

def get_points(item_container):
  """ liefert den Notenspiegel """
  if item_container.item.app.name=='dmsExercise':
    if item_container.item.integer_1 <= 0:
      return ''
    else:
      arr = string.splitfields(item_container.item.string_1.strip(), '\n')
      max = item_container.item.integer_1
  if item_container.item.app.name=='dmsEduExerciseItem':
    if item_container.item.integer_6 <= 0:
      return ''
    else:
      arr = string.splitfields(item_container.item.string_2.strip(), '\n')
      max = item_container.item.integer_6
  if len(arr) < 5:
    return ''
  error = False
  p = []
  for n in xrange(5):
    values = string.splitfields(arr[n].strip(), ':')
    if len(values) < 2:
      error = True
    else:
      if values[0].strip() != str(n):
        error = True
      if int(values[1].strip()) > max:
        error = True
      else:
        if n == 0:
          p.append({'max': max, 'min': int(values[1].strip())})
        else:
          p.append({'max': max-1, 'min': int(values[1].strip())})
        max = int(values[1].strip())
  p.append({'max': max, 'min': 0})
  return p
开发者ID:shagun30,项目名称:djambala-2,代码行数:35,代码来源:utils.py


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