Your IP : 216.73.216.213
B
�d{T�1 � @ sr d Z ddlmZ dZddlZddlZddlZddlmZm Z m
Z
mZmZm
Z
mZ ddlmZ ddlmZmZmZmZmZmZmZ ddlmZmZ dd lmZmZ dd
lmZ ddl m!Z! ddl"m#Z# d
d� Z$dd� Z%dd� Z&dd� Z'efdd�Z(G dd� de#�Z)G dd� de*�Z+dd� Z,dd� Z-e!d�e-�Z-d d!� Z.e!d"�e.�Z.d+d#d$�Z/d,d%d&�Z0eedfd'd(�Z1d-d)d*�Z2dS ).a3 File and file-path manipulation utilities.
:group path manipulation: first_level_directory, relative_path, is_binary,get_by_ext, remove_dead_links
:group file manipulation: norm_read, norm_open, lines, stream_lines, lines,write_open_mode, ensure_fs_mode, export
:sort: path manipulation, file manipulation
� )�print_functionzrestructuredtext enN)�isabs�isdir�islink�split�exists�normpath�join)�abspath)�sep�mkdir�remove�listdir�stat�chmod�walk)�ST_MODE�S_IWRITE)�
STD_BLACKLIST�IGNORED_EXTENSIONS)�find)�
deprecated)�FileIOc C s2 t | �\}}x|r$|r$t |�\}}qW |r.|S |S )a� Return the first level directory of a path.
>>> first_level_directory('home/syt/work')
'home'
>>> first_level_directory('/home/syt/work')
'/'
>>> first_level_directory('work')
'work'
>>>
:type path: str
:param path: the path for which we want the first level directory
:rtype: str
:return: the first level directory appearing in `path`
)r )�path�head�tail� r �I/opt/alt/python37/lib/python3.7/site-packages/logilab/common/fileutils.py�first_level_directory, s
r c s t � �� � fdd�t� �D �S )z�Lists path's content using absolute paths.
>>> os.listdir('/home')
['adim', 'alf', 'arthur', 'auc']
>>> abspath_listdir('/home')
['/home/adim', '/home/alf', '/home/arthur', '/home/auc']
c s g | ]}t � |��qS r )r )�.0�filename)r r r �
<listcomp>N s z#abspath_listdir.<locals>.<listcomp>)r
r )r r )r r �abspath_listdirE s r"