寻找文件路径，辅助函数

        :param symbol:
        :param subdir:
        :param ext:
        :return: pd.dataFrame or None
547452
def find_path(self, symbol=None, subdir='lday', ext='day'):
        '''
        
        '''
        market = get_stock_market(symbol, True)
        ext = ext if isinstance(ext, list) else [ext]

        for t in ext:
            vipdoc = 'vipdoc/{}/{}/{}{}.{}'.format(market, subdir, market, symbol, t)
            vipdoc = os.path.join(self.tdxdir, vipdoc)

            if os.path.exists(vipdoc):
                return vipdoc

        return None
454828
def get_ext(self, format=None, **kwargs):
        
        try:
            format = format or self.default_params['format']
            return ".%s" % format.lower()
        except KeyError: pass
689717
def evaluate(self, verbose=True, passes=None):
        
        if self.is_pivot:
            index, pivot, columns = LazyOpResult(
                self.expr,
                self.weld_type,
                0
            ).evaluate(verbose=verbose, passes=passes)
            df_dict = {}
            for i, column_name in enumerate(columns):
                df_dict[column_name] = pivot[i]
            return DataFrameWeld(pd.DataFrame(df_dict, index=index))
        else:
            df = pd.DataFrame(columns=[])
            weldvec_type_list = []
            for type in self.column_types:
                weldvec_type_list.append(WeldVec(type))

            columns = LazyOpResult(
                grizzly_impl.unzip_columns(
                    self.expr,
                    self.column_types
                ),
                WeldStruct(weldvec_type_list),
                0
            ).evaluate(verbose=verbose, passes=passes)

            for i, column_name in enumerate(self.column_names):
                df[column_name] = columns[i]

            return DataFrameWeld(df)
1262643
def _get_local_dirs(sub):
    
    path = os.environ.get("SPARK_LOCAL_DIRS", "/tmp")
    dirs = path.split(",")
    if len(dirs) > 1:
        # different order in different processes and instances
        rnd = random.Random(os.getpid() + id(dirs))
        random.shuffle(dirs, rnd.random)
    return [os.path.join(d, "python", str(os.getpid()), sub) for d in dirs]
59383
def file_extension(path):
    
    if path is None:
        return None
    ext = os.path.splitext(os.path.basename(path))[1]
    if ext.startswith("."):
        ext = ext[1:]
    return ext
233998
def load_directory(self, directory, **kwargs):
        
        log.setLevel(kwargs.get("log_level", self.log_level))
        conn = self.__get_conn__(**kwargs)
        file_extensions = kwargs.get('file_extensions', conn.rdf_formats)
        file_list = list_files(directory,
                               file_extensions,
                               kwargs.get('include_subfolders', False),
                               include_root=True)
        for file in file_list:
            self.load_file(file[1], **kwargs)
        log.setLevel(self.log_level)
928573
def get_conda_path():
    

    dstdir = ''
    # try:
    import subprocess
    import re
    # cond info --root work only for root environment
    # p = subprocess.Popen(['conda', 'info', '--root'], stdout=subprocess.PIPE,  stderr=subprocess.PIPE)
    p = subprocess.Popen(['conda', 'info', '-e'], stdout=subprocess.PIPE,  stderr=subprocess.PIPE)
    out, err = p.communicate()

    dstdir = out.strip()
    dstdir = re.search("\*(.*)\n", dstdir).group(1).strip()
    # except:
    #     import traceback
    #     traceback.print_exc()

    # import os.path as op
    # conda_pth = op.expanduser('~/anaconda/bin')
    # if not op.exists(conda_pth):
    #     conda_pth = op.expanduser('~/miniconda/bin')
    # return conda_pth
    return dstdir
211988
def get_ext_pillar_extra_minion_data(self, opts):
        '''
        
        '''
        def get_subconfig(opts_key):
            '''
            Returns a dict containing the opts key subtree, while maintaining
            the opts structure
            '''
            ret_dict = aux_dict = {}
            config_val = opts
            subkeys = opts_key.split(':')
            # Build an empty dict with the opts path
            for subkey in subkeys[:-1]:
                aux_dict[subkey] = {}
                aux_dict = aux_dict[subkey]
                if not config_val.get(subkey):
                    # The subkey is not in the config
                    return {}
                config_val = config_val[subkey]
            if subkeys[-1] not in config_val:
                return {}
            aux_dict[subkeys[-1]] = config_val[subkeys[-1]]
            return ret_dict

        extra_data = {}
        if 'pass_to_ext_pillars' in opts:
            if not isinstance(opts['pass_to_ext_pillars'], list):
                log.exception('\'pass_to_ext_pillars\' config is malformed.')
                raise SaltClientError('\'pass_to_ext_pillars\' config is '
                                      'malformed.')
            for key in opts['pass_to_ext_pillars']:
                salt.utils.dictupdate.update(extra_data,
                                             get_subconfig(key),
                                             recursive_update=True,
                                             merge_lists=True)
        log.trace('ext_pillar_extra_data = %s', extra_data)
        return extra_data
595308
def remove_symbol_from_dist(dist, index):
    '''
    
    '''
    if type(dist) is not Distribution:
        raise TypeError("remove_symbol_from_dist got an object ot type {0}".format(type(dist)))

    new_prob = dist.prob.copy()
    new_prob[index]=0
    new_prob /= sum(new_prob)
    return Distribution(new_prob)
53433
def ext_pillar(minion_id,
               pillar,  # pylint: disable=W0613
               repo_string):
    '''
    
    '''
    # split the branch, repo name and optional extra (key=val) parameters.
    options = repo_string.strip().split()
    branch = options[0]
    repo_location = options[1]
    root = ''

    for extraopt in options[2:]:
        # Support multiple key=val attributes as custom parameters.
        DELIM = '='
        if DELIM not in extraopt:
            log.error('Incorrectly formatted extra parameter. '
                      'Missing \'%s\': %s', DELIM, extraopt)
        key, val = _extract_key_val(extraopt, DELIM)
        if key == 'root':
            root = val
        else:
            log.warning('Unrecognized extra parameter: %s', key)

    svnpil = SvnPillar(branch, repo_location, root, __opts__)

    # environment is "different" from the branch
    branch = (branch == 'trunk' and 'base' or branch)

    pillar_dir = svnpil.pillar_dir()
    log.debug("[pillar_roots][%s] = %s", branch, pillar_dir)

    # Don't recurse forever-- the Pillar object will re-call the ext_pillar
    # function
    if __opts__['pillar_roots'].get(branch, []) == [pillar_dir]:
        return {}
    svnpil.update()
    opts = deepcopy(__opts__)
    opts['pillar_roots'][branch] = [pillar_dir]
    pil = Pillar(opts, __grains__, minion_id, branch)
    return pil.compile_pillar(ext=False)
480315
def directory(cls, prefix=None):
        
        prefix = prefix or utility.read_config().directory
        name = cls.__name__.lower()
        directory = os.path.expanduser(os.path.join(prefix, name))
        utility.ensure_directory(directory)
        return directory
175961
def df_all(self, phot):
        
        df = pd.concat([self.to_df(f) for f in self.get_filenames(phot)])
        return df
41822
def find(file_node, dirs=ICON_DIRS, default_name=None, file_ext='.png'):
        
        names = []
        for attr_name in ('extension', 'mimetype', 'mime_supertype'):
            attr = getattr(file_node, attr_name)
            if attr:
                names.append(attr)
        if default_name:
            names.append(default_name)
        icon_path = StaticPathFinder.find(names, dirs, file_ext)
        if icon_path:
            return StaticIconFile(file_node, icon_path)
685040
def _get_stem(self):
        
        filename = os.path.basename(self.src_path)
        stem, ext = os.path.splitext(filename)
        return "index" if stem in ("index", "README", "__init__") else stem
423237
def minute(self, symbol=None):
        '''
        
        '''
        symbol = self.find_path(symbol, subdir='minline', ext=['lc1', '1'])
        reader = TdxLCMinBarReader()

        if symbol is not None:
            return reader.get_df(symbol)

        return None
673235
def get_sub_dataframe(keys, by_position: true)
      return Daru::DataFrame.new({}) if keys == []

      keys = @index.pos(*keys) unless by_position

      sub_df = row_at(*keys)
      sub_df = sub_df.to_df.transpose if sub_df.is_a?(Daru::Vector)

      sub_df
    end
630431
def relative_path(sub_directory='', function_index=1):
    
    frm = inspect.currentframe()
    for i in range(function_index):
        frm = frm.f_back
    if frm.f_code.co_name == 'run_code':
        frm = frm.f_back

    if not isinstance(sub_directory, list):
        sub_directory = sub_directory.replace('\\','/').split('/')

    path = os.path.split(frm.f_code.co_filename)[0]
    if sub_directory:
        path = os.path.abspath(os.path.join(path, *sub_directory))
    return path