Utilpy Packages¶
utilpy.utils¶
-
utilpy.utils.
chunks
(l, n)[source]¶ Yield successive n-sized chunks from l.
- Args:
- l:
list
- list of data
- n:
int
- n-sized
- l:
- Return:
- list of list: [[]]
-
utilpy.utils.
clean_str
(string)[source]¶ Tokenization/string cleaning for all datasets except for SST. Original taken from https://github.com/yoonkim/CNN_sentence/blob/master/process_data.py
- Args:
- string:
str
- string of sentences
- string:
- Returns:
- Lowercase cleaned string:
str
-
utilpy.utils.
download_file
(url, save_dir='tmp/', filename=None)[source]¶ download and save the file
- Args:
- url:
str
- url of file
- save_dir:
str
- directory to save
- filename:
str
- Name of file to save as
- url:
-
utilpy.utils.
download_files
(urls, save_dir='tmp/')[source]¶ download all files from urls
- Args:
- urls:
list
- urls of file
- save_dir:
str
- directory to save
- urls:
-
utilpy.utils.
format_filename
(s)[source]¶ Take a string and return a valid filename constructed from the string. Uses a whitelist approach: any characters not present in valid_chars are removed. Also spaces are replaced with underscores.
- Args:
- s:
str
- string
- s:
- Returns:
- Valid filename :
str
-
utilpy.utils.
logger
(logger_name='utilpy.utils', filename='log.log', level=10)[source]¶ logger for logging
- Args:
- logger_name:
str
- name of logger
- filename:
str
- path and file name
- level:
str
- logging level
- logger_name:
- Return:
- logger funcation for logging:
logger
-
utilpy.utils.
page_soup
(url)[source]¶ Make BeautifulSoup of page
- Args:
- url:
str
- url of page
- url:
- Returns:
- BeautifulSoup of page:
soup
-
utilpy.utils.
read_config
(filename)[source]¶ Parse config yaml file
- Args:
- filename:
str
- path of config file
- filename:
-
utilpy.utils.
thread_pool
(func, args, threads)[source]¶ Run programe in thread
- Args:
- func:
object
- function to run in thread
- args:
list
- paramters to pass if multiple please use zip(args_list2, args_list2)
- threads:
int
- number of thread
- func:
- Return:
- list of result:
dict
utilpy.decorator¶
-
utilpy.decorator.
profile
(fnc)[source]¶ A decorator that uses cProfile to profile a function And print the result
utilpy.log¶
Logger function that print time required in each session of logger
utilspy.files¶
-
utilpy.files.
delete_dirs
(folder_names)[source]¶ delete folder and all its contents
- Args: `
- folder_names:str` or
list
- string or list of folders
- folder_names:str` or
-
utilpy.files.
make_dirs
(folder_names)[source]¶ make folder if it doesnot exist
- Args:
- folder_names:
str
orlist
- string or list of folders
- folder_names:
-
utilpy.files.
move_file
(filename, out_dir)[source]¶ move file/dir
- Args:
- filename:
str
- filename of file to be moved or name of dir to be moved
- out_dir:
str
- output directory
- filename:
-
utilpy.files.
parse_path
(path, fn_only=False, ext=False, al=True)[source]¶ get the directory from filename,
- Args:
- path:
str
- path of file
- fn_only:
bol
- get the file name only from path
- ext:
bol
- split file name into name and extension
- al:
bol
- get list of dir and file name
- path:
- Returns:
- list of value:
list