thutils package¶
Submodules¶
thutils.binary_writer module¶
@author: Tsuyoshi Hombashi
thutils.cache module¶
@author: Tsuyoshi Hombashi
thutils.common module¶
@author: Tsuyoshi Hombashi
-
class
thutils.common.
MinMaxObject
[source]¶ Bases:
thutils.common.BaseObject
-
average
()¶
-
diff
()¶
-
max_value
¶
-
min_value
¶
-
update
(value)¶
-
-
thutils.common.
compare_version
(lhs_version, rhs_version)[source]¶ <Major>.<Minor>.<Revision> 形式のバージョン文字列を比較する。
Returns: 0<: LHSがRHSより小さい 0: LHS == RHS 0>: LHSがRHSより大きい Return type: int
-
thutils.common.
humanreadable_to_byte
(readable_size, kilo_size=1024)[source]¶ Parameters: - str – readable_size. human readable size (bytes). e.g. 256 M
- int – size of kilo. 1024 or 1000
Raises: ValueError
-
thutils.common.
safe_division
(dividend, divisor)[source]¶ Returns: nan: invalid arguments Return type: float
-
thutils.common.
split_line_list
(line_list, re_line_separator=<_sre.SRE_Pattern object>, is_include_matched_line=False, is_strip=True)[source]¶
thutils.data_property module¶
@author: Tsuyoshi Hombashi
-
class
thutils.data_property.
Align
[source]¶ -
AUTO
= <thutils.data_property.__AlignData instance>¶
-
CENTER
= <thutils.data_property.__AlignData instance>¶
-
LEFT
= <thutils.data_property.__AlignData instance>¶
-
RIGHT
= <thutils.data_property.__AlignData instance>¶
-
-
class
thutils.data_property.
ColumnDataPeroperty
[source]¶ Bases:
thutils.common.BaseObject
-
align
¶
-
decimal_places
¶
-
padding_len
¶
-
typecode
¶
-
update_body
(prop)¶
-
update_header
(prop)¶
-
update_padding_len
(padding_len)¶
-
-
class
thutils.data_property.
DataPeroperty
(data)[source]¶ Bases:
thutils.common.BaseObject
-
additional_format_len
¶
-
align
¶
-
data
¶
-
decimal_places
¶
-
integer_digits
¶
-
str_len
¶
-
type_format
¶
-
typecode
¶
-
thutils.environment module¶
@author: Tsuyoshi Hombashi
-
class
thutils.environment.
EnvironmentInfo
[source]¶ -
EKN_DateTime
= 'Date Time'¶
-
EKN_PlatformMachine
= 'Platform Machine'¶
-
EKN_PlatformNode
= 'Platform Node'¶
-
EKN_PlatformProcessor
= 'Platform Processor'¶
-
EKN_PlatformRelease
= 'Platform Release'¶
-
EKN_PlatformSystem
= 'Platform System'¶
-
EKN_PlatformVersion
= 'Platform Version'¶
-
EKN_ProgramVersion
= 'Program Version'¶
-
EKN_PythonVersion
= 'Python Version'¶
-
KN_DistributionName
= 'Distribution Name'¶
-
KN_DistributionVersion
= 'Distribution Version'¶
-
thutils.gfile module¶
@author: Tsuyoshi Hombashi
-
class
thutils.gfile.
FileManager
[source]¶
-
class
thutils.gfile.
FileTypeChecker
[source]¶ -
-
classmethod
FileTypeChecker.
get_file_type
(file_path)¶
-
classmethod
FileTypeChecker.
is_text_file
(file_path)¶
-
classmethod
-
thutils.gfile.
check_file_existence
(path)[source]¶ Returns: FileType
Return type: int
Raises: - InvalidFilePathError –
- FileNotFoundError –
- RuntimeError –
-
thutils.gfile.
findFileAll
(search_root_dir_path, check_func, re_pattern_text, find_count=9223372036854775807)[source]¶
-
thutils.gfile.
parseLsPermissionText
(permission_text)[source]¶ parse “ls -l” style permission text: e.g. -rw-r–r–
thutils.gtime module¶
@author: Tsuyoshi Hombashi
-
class
thutils.gtime.
DateTimeRange
(start_datetime, end_datetime, time_format='%Y-%m-%d %H:%M:%S')[source]¶ Bases:
thutils.common.BaseObject
-
discard
(discard_percent)¶ 時間範囲の discard_percent / 2 [%] の時間分、開始・終了時刻をずらす。
-
end_datetime
¶
-
equals
(rhs)¶
-
getDeltaSecond
()¶
-
getEndTimeText
()¶
-
getOptionString
()¶
-
getStartTimeText
()¶
-
getTimeDelta
()¶ - Return value:
- datetime.timedelta
-
isValidTimeRange
()¶
-
isWithin
(input_datetime)¶
-
squeezeTimeRange
(datetime_range)¶ time inversionを発生させない範疇で時間範囲を狭める。
-
start_datetime
¶
-
to_string
(joint=' - ', time_format=None)¶
-
verifyTimeRange
()¶ - raise:
- TypeError ValueError
-
widenTimeRange
(datetime_range)¶ 時間範囲を広げる。
-
-
class
thutils.gtime.
Format
[source]¶ -
DATETIME_LIST
= ['%Y-%m-%d %H:%M:%S', '%Y%m%dT%H%M%S', '%Y-%m-%dT%H:%M:%S', '%Y/%m/%d %H:%M:%S']¶
-
class
Format.
ISO8601
¶
-
Format.
ISO_DATETIME_LIST
= ['%Y-%m-%d %H:%M:%S', '%Y%m%dT%H%M%S', '%Y-%m-%dT%H:%M:%S']¶
-
Format.
JST_DATE
= '%Y/%m/%d'¶
-
-
class
thutils.gtime.
RegularExpression
[source]¶ -
class
ISO
¶ -
DATE
= '[1-2][\\d]{3}-[0-1][\\d]-[0-3][\\d]'¶
-
DATETIME
= '[1-2][\\d]{3}-[0-1][\\d]-[0-3][\\d] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]'¶
-
DATETIME_WITH_TZ
= '[1-2][\\d]{3}-[0-1][\\d]-[0-3][\\d] [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [+-][\\d]{4}'¶
-
TIME
= '[0-2][0-9]:[0-5][0-9]:[0-5][0-9]'¶
-
TIMEZONE
= '[+-][\\d]{4}'¶
-
YEAR
= '[1-2][\\d]{3}'¶
-
-
class
thutils.loader module¶
@author: Tsuyoshi Hombashi
required: | https://pypi.python.org/pypi/voluptuous |
---|
-
class
thutils.loader.
JsonLoader
[source]¶ -
classmethod
load
(json_file_path, schema=None)¶ Parameters: json_file_path (str) – json_file_path: path of the json file to be read schema: voluptuous schema
Returns: Dictionary storing the parse results of JSON
Return type: dictionary
Raises: - ImportError –
- InvalidFilePathError –
- FileNotFoundError –
- RuntimeError –
- ValueError –
-
classmethod
loads
(json_text, schema=None)¶ Parameters: - json_text (str) – json text to be parse
- schema (voluptuous.Schema) – schema of voluptuous
Returns: Dictionary storing the parse results of JSON
Return type: dictionary
Raises: - ImportError –
- RuntimeError –
- ValueError –
-
classmethod
thutils.logger module¶
@author: Tsuyoshi Hombashi
-
class
thutils.logger.
LogLevelText
[source]¶ -
ERROR
= 'ERROR'¶
-
FATAL
= 'FATAL'¶
-
INFO
= 'INFO'¶
-
WARN
= 'WARN'¶
-
thutils.main module¶
@author: Tsuyoshi Hombashi
thutils.option module¶
@author: Tsuyoshi Hombashi
-
class
thutils.option.
ArgumentParserObject
[source]¶ Bases:
object
wrapper class of argparse
-
class
GroupName
[source]¶ -
MISC
= 'Miscellaneous'¶
-
PROFILE
= 'Profile'¶
-
SQL
= 'SQL'¶
-
TIME_RANGE
= 'Time Range'¶
-
-
class
thutils.sqlite module¶
@author: Tsuyoshi Hombashi
-
class
thutils.sqlite.
SqlQuery
[source]¶
-
class
thutils.sqlite.
SqliteWrapper
(dry_run=False, profile=False)[source]¶ Bases:
object
wrapper class of sqlite3
-
AN_DB_CREATE_TIME
= 'database_create_time'¶
-
AN_DB_NAME
= 'database_name'¶
-
AN_DB_VERSION
= 'database_version'¶
-
MISC_TABLE_LIST
= ['table_configuration', 'database_information', 'sql_profile']¶
-
TN_DB_INFO
= 'database_information'¶
-
TN_SQL_PROFILE
= 'sql_profile'¶
-
TN_TABLE_CONFIG
= 'table_configuration'¶
-
check_connection
()[source]¶ Raises: NullDatabaseConnectionError – if not connected to a SQLite database file
-
check_database_name
(expected_name)[source]¶ Raises: - TableNotFoundError – table not found in the database
- AttributeError – attribute not found in the database
- MissmatchError – database name missmatch found
-
check_database_version
(compare_version)[source]¶ Raises: - TableNotFoundError – table not found in the database
- AttributeError – attribute not found in the database
- MissmatchError – database version miss match found
-
connect
(database_path, mode='w')[source]¶ Parameters: mode (str) – “r”: read only “w”: DBファイルを新規作成する。既存ファイルは削除する。 “a”: 既存DBファイルに追記する。
Raises: - TypeError –
- database_path が文字列でない
- mode が文字列でない
- FileNotFoundError – database_path not found
- InvalidFilePathError – database_path is invalid
- ValueError –
- database_path がディレクトリ
- mode が未サポートの値
- DatabaseError – file is not a valid SQLite binary file
- TypeError –
-
connection
¶
-
create_table_with_data
(table_name, attribute_name_list, data_matrix, index_attribute_list=())[source]¶
-
database_path
¶
-
dry_run
¶
-
mode
¶
-
thutils.subprocwrapper module¶
@author: Tsuyoshi Hombashi