pydong package

Submodules

pydong.cli module

Console script for pydong.

pydong.cli.main()[source]

Console script for pydong.

pydong.pydong module

Main module.

pydong.utils module

common file

pydong.utils.format_df(df, int_format='{:,}', float_format='{:,4f}')[source]

Formats the columns of pandas.DataFrame with the type of int and float

Parameters

dfpandas.DataFrame

the df to revise

int_format: str, optional

the format of int columns, refer to the python f-string

float_format: str, optional

the format of float columns, refer to the python f-string

Returns

pandas.DataFrame

pydong.utils.log(file_name=None, logger_name='pydong.utils', quite=False)[source]

logging template

Parameters

file_namestr, default None

if set, will generate log file.

logger_namestr, default __name__

logger name

quitebool, default False

if True, set log level to ERROR else INFO

Returns

logger

pydong.utils.safe_open(file_name, mode='r')[source]

open the file safely

Parameters

file_namestr

the name of file path

modestr, optional

the opem mode, by default ‘r’

Returns

file_handle

pydong.utils.safe_run(shell_cmd, retry=3, has_retry=0)[source]

Return linux command line executive result

Parameter

shell_cmdstr

linux command

retryint, default 3

the number of retry if command fail

has_retry: int, default 0

the number of retry which has run

pydong.utils.str2time(string, f='%Y-%m-%d %H:%M:%S')[source]

Convert string to datetime

pydong.utils.time2str(dt, f='%Y-%m-%d %H:%M:%S')[source]

Convert time to string

pydong.utils.try_except(f)[source]

the decoratTry/Except decorator

Parameters

ffunction

the function to be test

Module contents

Top-level package for pydong.