If catalog is named 'catalog' take name from parent directory
356194
def name_from_path(self):
        """"""
        name = os.path.splitext(os.path.basename(self.path))[0]
        if name == 'catalog':
            name = os.path.basename(os.path.dirname(self.path))
        return name.replace('.', '_')
957529
def _maybe_init_metadata_dir_by_name(self, name):
    """"""
    safe_mkdir(self.__class__._get_metadata_dir_by_name(name, self._metadata_base_dir))
876337
def cleanup_tmpdir(dirname):
    """"""
    if dirname is not None and os.path.exists(dirname):
        shutil.rmtree(dirname)
1063372
def _get_phantom_root_catalog(self, cat_name, cat_class):
        """"""
        catalog_map = make_catalog_map(cat_name, identifier=PHANTOM_ROOT_IDENTIFIER)
        return cat_class(osid_object_map=catalog_map, runtime=self._runtime, proxy=self._proxy)
1077061
def validate_name(ctx, param, value):
    """"""
    if not value:
        value = os.path.basename(ctx.params['directory'].rstrip(os.path.sep))
    return value
66962
def _clean_directory(self, name):
        """"""
        if not os.path.exists(name):
            return
        self.announce(
            "removing directory '{}' and all its contents".format(name)
        )
        if not self.dry_run:
            rmtree(name, True)
1240893
def directory(self, value):
        """"""
        # Normalize the value of `directory'.
        set_property(self, "directory", parse_path(value))
        # Clear the computed values of `context' and `entries'.
        clear_property(self, "context")
        clear_property(self, "entries")
1215922
def fetch_parent_dir(filepath, n=1):
    '''
    '''
    filepath = os.path.realpath(filepath)
    for i in range(n):
        filepath = os.path.dirname(filepath)
    return os.path.basename(filepath)
1030138
def load_combo_catalog():
    """"""
    user_dir = user_data_dir()
    global_dir = global_data_dir()
    desc = 'Generated from data packages found on your intake search path'
    cat_dirs = []
    if os.path.isdir(user_dir):
        cat_dirs.append(user_dir + '/*.yaml')
        cat_dirs.append(user_dir + '/*.yml')
    if os.path.isdir(global_dir):
        cat_dirs.append(global_dir + '/*.yaml')
        cat_dirs.append(global_dir + '/*.yml')
    for path_dir in conf.get('catalog_path', []):
        if path_dir != '':
            if not path_dir.endswith(('yaml', 'yml')):
                cat_dirs.append(path_dir + '/*.yaml')
                cat_dirs.append(path_dir + '/*.yml')
            else:
                cat_dirs.append(path_dir)

    return YAMLFilesCatalog(cat_dirs, name='builtin', description=desc)
1189710
def parent_directory(self):
        """"""
        self.chdir(os.path.join(getcwd_or_home(), os.path.pardir))
997648
def get_catalog_path(catalog_id, catalogs_dir=CATALOGS_DIR, fmt="json"):
    """"""

    base_path = os.path.join(catalogs_dir, "catalog", catalog_id)
    if fmt == "json":
        return os.path.join(base_path, "data.json")
    elif fmt == "xlsx":
        return os.path.join(base_path, "catalog.xlsx")
    else:
        raise NotImplementedError("El formato {} no está implementado.".format(
            fmt))
309846
private DirectoryEntry getNormalizedParent( DirectoryEntry parent )
    {
        if ( parent.getParent() == null )
        {
            return getRoot();
        }
        else
        {
            return mkdir( parent.getParent(), parent.getName() );
        }
    }
316911
def Dirname(self):
    """"""
    result = self.Copy()

    while 1:
      last_directory = posixpath.dirname(result.last.path)
      if last_directory != "/" or len(result) <= 1:
        result.last.path = last_directory
        # Make sure to clear the inode information.
        result.last.inode = None

        break

      result.Pop(-1)

    return result
947750
def libname_from_dir(dirname):
    """"""
    parts = []
    for part in dirname.split('-'):
        if part[0].isdigit():
            break
        parts.append(part)
    return '-'.join(parts)
1083566
def find(name):
    """"""

    if op.exists(name):
        return name

    path = op.dirname(__file__) or '.'

    paths = [path] + config['include_path']

    for path in paths:
        filename = op.abspath(op.join(path, name))
        if op.exists(filename):
            return filename

        for d in os.listdir(path):
            fullpath = op.abspath(op.join(path, d))
            if op.isdir(fullpath):
                filename = op.abspath(op.join(fullpath, name))
                if op.exists(filename):
                    return filename

    return None
785142
def _enter_single_subdir(root_dir):
    """"""
    current_cwd = os.getcwd()
    try:
        dest_dir = root_dir
        dir_list = os.listdir(root_dir)
        if len(dir_list) == 1:
            first = os.path.join(root_dir, dir_list[0])
            if os.path.isdir(first):
                dest_dir = first
        else:
            dest_dir = root_dir
        os.chdir(dest_dir)
        yield dest_dir
    finally:
        os.chdir(current_cwd)
1152996
def mkdir(dir_path):
        # type: (AnyStr) -> None
        """"""
        if not os.path.isdir(dir_path) or not os.path.exists(dir_path):
            os.makedirs(dir_path)