srb提供的python库
srblib的Python项目详细描述
srblib
srblib是一个umberalla python库,用于保存可用于其他项目的有用python脚本。
它不仅仅是一个library。它是一个透视图。
安装
使用PIP安装(推荐)
- 使用pip安装,用户
--user
标志
python3 -m pip install --user srblib
从源代码生成
- 克隆存储库并签出到稳定提交
git clone https://github.com/srbcheema1/srblib
cd srblib
git checkout <latest_version say: v0.0.x>
- 安装要求
python3 -m pip install --user -r requirements.txt
- 安装srblib
python3 setup.py install --user
- 建筑源分布
python3 setup.py sdist
提供的课程
- color-一个带有颜色名称和静态打印函数的类,它将彩色输出打印到stderr
Colour.print(message,Colour.RED) # for foreground as red
Colour.print(message,Colour.FULLGREEN) # for background as green
Colour.print(message,Colour.FULLGREEN+Colour.RED) # for background as fullgreen and foreground as RED
- 电子邮件-发送电子邮件的类
a = Email()
a.fromaddr = 'sender@gmail.com'
a.toaddr = 'receiver@gmail.com'
a.password = 'password'
a.body = "test mail"
a.subject = "test subject"
a.send()
- srbbank—一个类,用于存储程序稍后使用的内容。可以用作数据库
a = SrbBank('db_name') #say the db_name is your database name
a['hello'] = "world"
b = SrbBank('db2','password')
b['hello'] = "peeps"
# EXIT THE CODE AND START NEW SESSION
a = SrbBank('db_name')
print(a['hello']) # 'world'
b = SrbBank('db2','password')
print(b['hello']) # 'peeps'
- srbjson-一个更容易使用json文件的类
a = SrbJson('json/path')
a['hello'] = 'world'
# EXIT THE CODE AND START NEW SESSION
a = SrbJson('json/path')
print(a['hello']) # 'world'
- tabular-一个用于用户表格数据和读写json、xlsx、csv文件的类
a = Tabular('path/to/file') # can take files with extension as csv,json,xlsx
print(a) # prints table in tabular form
data = a.matrix # get data in form of list of lists i.e. matrix
json_data = a.json # get data in form of list of dictionaries i.e. json
print(a[1]['name']) # here name is the attribute used to name the columns
print(a[0]) # prints attributes
print(a[1]) # prints 1st row (0 based)
print(a['name']) # prints column with attribute 'name'
a.write_xls('output/path')
a.write_csv('output/path')
a.write_json('output/path')
NOTE: it reads blank and empty cells from excel file as None
NOTE: to read excel file in strict mode please call obj.load_xls(path,strict=True)
- module-导入具有变量路径的文件的类
a = Module('/path/to/file')
a.function_in_that_file()
print(a.variable_in_that_file)
- soup-一个有助于废弃的类,参数应该是url或美化组对象
soup = BeautifulSoup('<p><div class="good">hello</div><div>world</div></p>','html.parser')
a = Soup(soup)
print(a) # prints it in pretty way
b = a['div',{'class':'good'}] # [<div class="good">hello</div>]
b = a[lambda tag: tag.name == 'div'] # [<div class="good">hello</div>, <div>world</div>]
a = Soup('http://gitub.com/srbcheema1')
b = a['div'][1]['p'] # cascading in [] operators they work similar to find_all function, save space
text_output = a['div'][1]['p'].text # we can call any function or variable that we could call on soup
soup = b.soup # get original soup object
提供的功能
- 返回给定路径的绝对路径。适用于windows和linux。
- get_os_name-返回os name。值为Windows、Linux或Mac
- 是否已安装-检查是否在计算机上安装了以下应用程序
- file_extension-从文件路径返回文件的扩展名,如果没有ext,则可能返回''
- 文件名-从文件路径返回文件名
- 移除-递归移除路径。它将删除该路径下的所有文件和文件夹
- VelIFyx文件-验证文件是否存在。如果不是,它将创造一个。如果需要,还可以创建父对象
< >验证文件夹是否存在。如果不存在,则创建一个。如果需要,还可以创建父对象- 相似性-返回两个字符串中相似性的百分比。
- str_hash-对字符串进行哈希运算
- path_hash-散列完整路径
提供的变量
- debug-其值可以在~/.config/srblib/debug.json中更改的布尔值
- 在Windows上-值为
True
的布尔值在Windows上运行
- 在ci上-值为
True
的布尔值在ci上运行
联系人/社交媒体
git clone https://github.com/srbcheema1/srblib
cd srblib
git checkout <latest_version say: v0.0.x>
python3 -m pip install --user -r requirements.txt
python3 setup.py install --user
python3 setup.py sdist
Colour.print(message,Colour.RED) # for foreground as red
Colour.print(message,Colour.FULLGREEN) # for background as green
Colour.print(message,Colour.FULLGREEN+Colour.RED) # for background as fullgreen and foreground as RED
a = Email()
a.fromaddr = 'sender@gmail.com'
a.toaddr = 'receiver@gmail.com'
a.password = 'password'
a.body = "test mail"
a.subject = "test subject"
a.send()
a = SrbBank('db_name') #say the db_name is your database name
a['hello'] = "world"
b = SrbBank('db2','password')
b['hello'] = "peeps"
# EXIT THE CODE AND START NEW SESSION
a = SrbBank('db_name')
print(a['hello']) # 'world'
b = SrbBank('db2','password')
print(b['hello']) # 'peeps'
a = SrbJson('json/path')
a['hello'] = 'world'
# EXIT THE CODE AND START NEW SESSION
a = SrbJson('json/path')
print(a['hello']) # 'world'
a = Tabular('path/to/file') # can take files with extension as csv,json,xlsx
print(a) # prints table in tabular form
data = a.matrix # get data in form of list of lists i.e. matrix
json_data = a.json # get data in form of list of dictionaries i.e. json
print(a[1]['name']) # here name is the attribute used to name the columns
print(a[0]) # prints attributes
print(a[1]) # prints 1st row (0 based)
print(a['name']) # prints column with attribute 'name'
a.write_xls('output/path')
a.write_csv('output/path')
a.write_json('output/path')
NOTE: it reads blank and empty cells from excel file as None
NOTE: to read excel file in strict mode please call obj.load_xls(path,strict=True)
a = Module('/path/to/file')
a.function_in_that_file()
print(a.variable_in_that_file)
soup = BeautifulSoup('<p><div class="good">hello</div><div>world</div></p>','html.parser')
a = Soup(soup)
print(a) # prints it in pretty way
b = a['div',{'class':'good'}] # [<div class="good">hello</div>]
b = a[lambda tag: tag.name == 'div'] # [<div class="good">hello</div>, <div>world</div>]
a = Soup('http://gitub.com/srbcheema1')
b = a['div'][1]['p'] # cascading in [] operators they work similar to find_all function, save space
text_output = a['div'][1]['p'].text # we can call any function or variable that we could call on soup
soup = b.soup # get original soup object
True
的布尔值在Windows上运行
True
的布尔值在ci上运行
由
开发开发者/作者:Srb Cheema