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


Python path.find方法代码示例

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


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

示例1: list_videos

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def list_videos(channel,param):
  videos=[] 
  
  filePath=utils.downloadCatalog('https://docs.google.com/spreadsheets/d/%s/pubhtml' % (param),'%s.HTML' % (param),False,{})  
  html=open(filePath).read()
  match = re.compile(r'<td class="s16" dir="ltr">(.*?)</td><td class="s16" dir="ltr">(.*?)</td><td class="s15" dir="ltr">(.*?)</td>',re.DOTALL).findall(html)
  #match = re.compile(r'<td class="s16" dir="ltr">(.*?)</td><td class="s16" dir="ltr">(.*?)</td><td class="s15" dir="ltr">(.*?)
  if match:
    for title,path,cnt in match:
      pIndex=path.find('&amp;p=')  
      chan= path[3:pIndex]  
      url=path[pIndex+7:]
      infoLabels={ "Title": title,"Plot":cnt + ' ' + globalvar.LANGUAGE(33039).encode('utf-8')}
      videos.append( [chan, url,title, os.path.join( globalvar.MEDIA, chan +".png"),infoLabels,'play'] ) 
    
  return videos 
开发者ID:spmjc,项目名称:plugin.video.freplay,代码行数:18,代码来源:mostviewed.py

示例2: _search_data

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def _search_data(self, data):
        """Recursive, breadth-first search for usable tabular data (JSON array of arrays or array of objects)
        @param data: top level of the JSON data to search
        @returns: the 
        """

        if hxl.datatypes.is_list(data):
            data_in = data
        elif isinstance(data, dict):
            data_in = data.values()
        else:
            return None

        # search the current level
        for item in data_in:
            if self._scan_data_element(item):
                return item

        # recursively search the children
        for item in data_in:
            data_out = self._search_data(item)
            if data_out is not None:
                return data_out

        return None # didn't find anything 
开发者ID:HXLStandard,项目名称:libhxl-python,代码行数:27,代码来源:io.py

示例3: __find_subpath

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def __find_subpath( self, path, subpath ):
        """
        Return sub-path but only if enclosed by path separators.
        Looks complicated for what it does...
        """
        if os.path.sep == '/':
            seps = [ i for i in range( len(path) ) if path[i]==os.path.sep ]
        else:
            seps = [ i for i in range( len(path) ) \
                     if path[i] in [os.path.sep, '/', ':'] ]
            
        seps += [ len( path ) ]

        pos = path.find( subpath )

        if pos in seps and pos+len(subpath) in seps:
            return pos

        return -1 
开发者ID:graik,项目名称:biskit,代码行数:21,代码来源:localpath.py

示例4: __is_path

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def __is_path( self, o, minLen=3 ):
        """
        Check whether an object is a path string (existing or not).
        
        :param minLen: minimal length of string o to be counted as path
        :type  minLen: int
        
        :return: 1|0
        :rtype: int
        """
        r = ( type( o ) == str \
              and (o.find(os.path.sep) != -1 or o.find('/') != -1)\
              and len(o) >= minLen )
##              and o.find(':') == -1 )
        if r:
            try:
                s = T.absfile( o )
                return 1
            except:
                return 0
        return 0 
开发者ID:graik,项目名称:biskit,代码行数:23,代码来源:localpath.py

示例5: get_all_dirs

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def get_all_dirs():
    dirs = []
    paths = var.music_db.query_all_paths()
    for path in paths:
        pos = 0
        while True:
            pos = path.find("/", pos + 1)
            if pos == -1:
                break
            folder = path[:pos]
            if folder not in dirs:
                dirs.append(folder)

    return dirs 
开发者ID:azlux,项目名称:botamusique,代码行数:16,代码来源:interface.py

示例6: _select

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def _select(self, selector, data):
        """Find the JSON matching the selector"""
        if selector is None:
            # no selector
            return data
        elif hxl.datatypes.is_token(selector):
            # legacy selector (top-level JSON object property)
            if not isinstance(data, dict):
                raise HXLParseException("Expected a JSON object at the top level for simple selector {}".format(selector))
            if selector not in data:
                raise HXLParseException("Selector {} not found at top level of JSON data".format(selector))
            return data[selector]
        else:
            # full JSONpath
            path = jsonpath_ng.ext.parse(selector)
            matches = path.find(data)
            if len(matches) == 0:
                raise HXLParseException("No matches for JSONpath {}".format(selector))
            else:
                # Tricky: we have multiple matches
                # Do we want a list of all matches, or just the first match?
                # Try to guess from the first value matched
                values = [match.value for match in matches]
                if len(values) > 0 and self._scan_data_element(values[0]):
                    return values[0]
                else:
                    return values
            raise HXLParseException("JSONPath results for {} not usable as HXL data".format()) 
开发者ID:HXLStandard,项目名称:libhxl-python,代码行数:30,代码来源:io.py

示例7: load

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def load( self ):
        """
        Try to unpickle an object from the currently valid path.
        
        :return: unpickled object 
        :rtype: any
        
        :raise IOError: if file can not be found
        """
        try:
            return T.load( self.local( existing=1 ) )
        except LocalPathError as why:
            raise IOError("Cannot find file %s (constructed from %s)" %\
                  self.local()).with_traceback(str( self )) 
开发者ID:graik,项目名称:biskit,代码行数:16,代码来源:localpath.py

示例8: parse_blob_uri

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def parse_blob_uri(blob_uri):
    path = get_path_from_uri(blob_uri).strip('/')
    first_sep = path.find('/')
    if first_sep == -1:
        waagent.AddExtensionEvent(name=ExtensionShortName, op="EnableInProgress", isSuccess=False,
                                  message="Error occured while extracting container and blob name.")
        hutil.error("Failed to extract container and blob name from " + blob_uri)
    blob_name = path[first_sep + 1:]
    container_name = path[:first_sep]
    return (blob_name, container_name) 
开发者ID:Azure,项目名称:azure-linux-extensions,代码行数:12,代码来源:dsc.py

示例9: get_host_base_from_uri

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def get_host_base_from_uri(blob_uri):
    uri = urllib.parse.urlparse(blob_uri)
    netloc = uri.netloc
    if netloc is None:
        return None
    return netloc[netloc.find('.'):] 
开发者ID:Azure,项目名称:azure-linux-extensions,代码行数:8,代码来源:dsc.py

示例10: get_host_base_from_uri

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def get_host_base_from_uri(blob_uri):
    uri = urlparse(blob_uri)
    netloc = uri.netloc
    if netloc is None:
        return None
    return netloc[netloc.find('.'):] 
开发者ID:Azure,项目名称:azure-linux-extensions,代码行数:8,代码来源:customscript.py

示例11: get_properties_from_uri

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def get_properties_from_uri(uri, hutil):
    path = get_path_from_uri(uri)
    if path.endswith('/'):
        path = path[:-1]
    if path[0] == '/':
        path = path[1:]
    first_sep = path.find('/')
    if first_sep == -1:
        hutil.error("Failed to extract container, blob, from {}".format(path))
    blob_name = path[first_sep+1:]
    container_name = path[:first_sep]
    return {'blob_name': blob_name, 'container_name': container_name} 
开发者ID:Azure,项目名称:azure-linux-extensions,代码行数:14,代码来源:customscript.py

示例12: read_input

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def read_input(path):
    if path.find('mask') > 0 and (path.find('CHASEDB1') > 0 or path.find('STARE') > 0):
        fn = lambda x: 1.0 if x > 0.5 else 0
        x = np.array(Image.open(path).convert('L').point(fn, mode='1')) / 1.
    elif path.find('2nd') > 0 and path.find('DRIVE') > 0:
        x = np.array(Image.open(path)) / 1.
    elif path.find('_manual') > 0 and path.find('CHASEDB1') > 0:
        x = np.array(Image.open(path)) / 1.
    else:
        x = np.array(Image.open(path)) / 255.
    if x.shape[-1] == 3:
        return x
    else:
        return x[..., np.newaxis] 
开发者ID:conscienceli,项目名称:IterNet,代码行数:16,代码来源:prepare_dataset.py

示例13: preprocessData

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def preprocessData(data_path, dataset):
    global DESIRED_DATA_SHAPE

    data_path = list(sorted(glob(data_path)))

    if data_path[0].find('mask') > 0:
        return np.array([read_input(image_path) for image_path in data_path])
    else:
        return np.array([resize(read_input(image_path), DESIRED_DATA_SHAPE) for image_path in data_path]) 
开发者ID:conscienceli,项目名称:IterNet,代码行数:11,代码来源:prepare_dataset.py

示例14: get_existing_cluster

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def get_existing_cluster(conn, opts, cluster_name, die_on_error=True):
    """
    Get the EC2 instances in an existing cluster if available.
    Returns a tuple of lists of EC2 instance objects for the masters and slaves.
    """
    print("Searching for existing cluster {c} in region {r}...".format(
          c=cluster_name, r=opts.region))

    def get_instances(group_names):
        """
        Get all non-terminated instances that belong to any of the provided security groups.

        EC2 reservation filters and instance states are documented here:
            http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options
        """
        reservations = conn.get_all_reservations(
            filters={"instance.group-name": group_names})
        instances = itertools.chain.from_iterable(r.instances for r in reservations)
        return [i for i in instances if i.state not in ["shutting-down", "terminated"]]

    master_instances = get_instances([cluster_name + "-master"])
    slave_instances = get_instances([cluster_name + "-slaves"])

    if any((master_instances, slave_instances)):
        print("Found {m} master{plural_m}, {s} slave{plural_s}.".format(
              m=len(master_instances),
              plural_m=('' if len(master_instances) == 1 else 's'),
              s=len(slave_instances),
              plural_s=('' if len(slave_instances) == 1 else 's')))

    if not master_instances and die_on_error:
        print("ERROR: Could not find a master for cluster {c} in region {r}.".format(
              c=cluster_name, r=opts.region), file=sys.stderr)
        sys.exit(1)

    return (master_instances, slave_instances)



# Execute a cmd on master and slave nodes 
开发者ID:yahoo,项目名称:TensorFlowOnSpark,代码行数:42,代码来源:spark_ec2.py

示例15: __substitute

# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import find [as 别名]
def __substitute( self, fragments, name, value ):
        """
        Look in all not yet substituted fragments for parts that can be
        substituted by value and, if successful, create a new fragment
        
        :param fragments: fragment tuples
        :type  fragments: [ (str, str) ]
        :param name: substitution variable name
        :type  name: str
        :param value: susbtitution value in current environment
        :type  value: str
        
        :return: fragment tuples
        :rtype: [ (str, str) ]
        """
        result = []

        try:
            for abs, subst in fragments:

                if not subst:   ## unsubstituted fragment

##                     pos = abs.find( value )
                    pos = self.__find_subpath( abs, value )

                    if pos != -1:
                        end = pos + len( value )

                        f1, f2, f3 = abs[0:pos], abs[pos:end], abs[end:]

                        if f1:
                            result += [ (f1, None) ] ## unsubstituted head
                        result += [ (f2, name) ]     ## new substitution
                        if f3:
                            result += [ (f3, None) ] ## unsubstituted tail

                    else:
                        result += [ (abs, subst) ]
                else:
                    result += [ (abs, subst ) ]
        except OSError as why:
            EHandler.fatal("Substituting path fragments: \n" +
                                 str( fragments ) + '\nname: ' + str( name ) +
                                 '\nvalue:' + str( value ) )

        return result 
开发者ID:graik,项目名称:biskit,代码行数:48,代码来源:localpath.py


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