bip.utils package¶
Submodules¶
bip.utils.app module¶
-
class
bip.utils.app.
Application
(import_name, static_url_path=None, static_folder='static', static_host=None, host_matching=False, subdomain_matching=False, template_folder='templates', instance_path=None, instance_relative_config=False, root_path=None)¶ Klasy bazowe:
flask.app.Flask
Overriden application class.
bip.utils.cli module¶
-
class
bip.utils.cli.
ColAlign
¶ Klasy bazowe:
object
Column alignment enum
-
center
= 'c'¶
-
left
= 'l'¶
-
right
= 'r'¶
-
-
class
bip.utils.cli.
ColDataType
¶ Klasy bazowe:
object
Column data type enum
-
auto
= 'a'¶
-
exp
= 'e'¶
-
float
= 'f'¶
-
int
= 'i'¶
-
text
= 't'¶
-
-
class
bip.utils.cli.
ColSpec
(align, dtype, title)¶ Klasy bazowe:
tuple
Create new instance of ColSpec(align, dtype, title)
-
property
align
¶ Alias for field number 0
-
property
dtype
¶ Alias for field number 1
-
property
title
¶ Alias for field number 2
-
property
-
bip.utils.cli.
create_table
(is_testing: bool, cols: List[bip.utils.cli.ColSpec]) → texttable.Texttable¶ Create table for term display. The table has unlimited size if application is in testing state, otherwise term size.
-
bip.utils.cli.
login_user
(username: str, admin: bool = True) → bip.models.User¶ Verify user login.
-
bip.utils.cli.
print_table
(table: texttable.Texttable)¶ Print table to terminal or to pager depending on table size.
- Parametry
table (
Texttable
) – table to be printed
bip.utils.files module¶
-
class
bip.utils.files.
FileData
(filename, file_type, file_size)¶ Klasy bazowe:
tuple
Create new instance of FileData(filename, file_type, file_size)
-
property
file_size
¶ Alias for field number 2
-
property
file_type
¶ Alias for field number 1
-
property
filename
¶ Alias for field number 0
-
property
-
bip.utils.files.
calc_sha256
(filename: str) → str¶ Calculate SHA256 checksum without reading whole file into memory.
-
bip.utils.files.
process_incoming_file
(path: str, target_dir: str) → bip.utils.files.FileData¶ Processing of incoming page attachment file.
bip.utils.forms module¶
-
class
bip.utils.forms.
BaseForm
(*args, **kwargs)¶ Klasy bazowe:
flask_wtf.form.FlaskForm
- Parametry
formdata – Used to pass data coming from the enduser, usually request.POST or equivalent. formdata should be some sort of request-data wrapper which can get multiple parameters from the form input, and values are unicode strings, e.g. a Werkzeug/Django/WebOb MultiDict
obj – If formdata is empty or not provided, this object is checked for attributes matching form field names, which will be used for field values.
prefix – If provided, all fields will have their name prefixed with the value.
data – Accept a dictionary of data. This is only used if formdata and obj are not present.
meta – If provided, this is a dictionary of values to override attributes on this form’s meta instance.
**kwargs – If formdata is empty or not provided and obj does not contain an attribute named the same as a field, form will assign the value of a matching keyword argument to the field, if one exists.
-
class
bip.utils.forms.
Button
(type_: str = 'submit', class_: str = 'primary', icon: str = 'check', icon_type: str = 'fas', text: str = 'ok')¶ Klasy bazowe:
bip.utils.forms.Renderable
-
class
bip.utils.forms.
Link
(href: str, text: str = 'klik')¶ Klasy bazowe:
bip.utils.forms.Renderable
-
class
bip.utils.forms.
ObjectForm
(*args, **kwargs)¶ Klasy bazowe:
bip.utils.forms.BaseForm
- Parametry
formdata – Used to pass data coming from the enduser, usually request.POST or equivalent. formdata should be some sort of request-data wrapper which can get multiple parameters from the form input, and values are unicode strings, e.g. a Werkzeug/Django/WebOb MultiDict
obj – If formdata is empty or not provided, this object is checked for attributes matching form field names, which will be used for field values.
prefix – If provided, all fields will have their name prefixed with the value.
data – Accept a dictionary of data. This is only used if formdata and obj are not present.
meta – If provided, this is a dictionary of values to override attributes on this form’s meta instance.
**kwargs – If formdata is empty or not provided and obj does not contain an attribute named the same as a field, form will assign the value of a matching keyword argument to the field, if one exists.
-
class
bip.utils.forms.
Renderable
¶ Klasy bazowe:
object
An object that can be rendered
-
render
() → markupsafe.Markup¶ Render template into
Markup
object.- Zwraca
rendering result as Markup
- Typ zwracany
Markup
-
bip.utils.http module¶
-
bip.utils.http.
or_404
(obj: Optional[Any]) → Any¶ Abort with 404 if passed object is None.
- Parametry
obj (Optional[Any]) – something to be checked for None
- Zwraca
passed object if it’s not None
- Typ zwracany
Any
bip.utils.pagination module¶
-
class
bip.utils.pagination.
Pagination
(query, page, per_page, total, items)¶ Klasy bazowe:
object
Copied almost verbatim from Flask-SQLAlchemy. Minor changes made to work with Peewee query object. Removed unused code.
Copyright 2010 Pallets
-
iter_pages
(left_edge=2, left_current=2, right_current=5, right_edge=2)¶
-
property
has_next
¶ True if a next page exists.
-
property
has_prev
¶ True if a previous page exists
-
property
pages
¶ The total number of pages
-
-
bip.utils.pagination.
get_page
(arg_name: str = 'p') → int¶ Get page number for current request. Page number is searched in request args.
-
bip.utils.pagination.
paginate
(query: peewee.Query, page: Optional[int] = None, size: Optional[int] = None) → bip.utils.pagination.Pagination¶ Create pagination object using sane defaults.
- Parametry
- Zwraca
pagination object for query
- Typ zwracany
bip.utils.site module¶
-
class
bip.utils.site.
Address
(street: «str», zip_code: «str», town: «str»)¶ Klasy bazowe:
object
-
property
display_value
¶
-
property
-
class
bip.utils.site.
Contact
(phone: «str», email: «str», name: «str» = '')¶ Klasy bazowe:
object
-
property
basic_information
¶
-
property
-
class
bip.utils.site.
Department
(name: «str», staff: «List[StaffMember]», phone: «str» = '', email: «str» = '', domain: «str» = '', location: «str» = '')¶ Klasy bazowe:
object
-
classmethod
from_dict
(d: dict) → bip.utils.site.Department¶
-
property
basic_information
¶
-
staff
: List[bip.utils.site.StaffMember]¶
-
classmethod
-
class
bip.utils.site.
Site
(name: «str», address: «Address», contacts: «List[Contact]», departments: «List[Department]», bip_url: «str», nip: «str», regon: «str», short_name: «str» = '', krs: «str» = '')¶ Klasy bazowe:
object
-
classmethod
from_dict
(d: dict) → bip.utils.site.Site¶
-
classmethod
from_json
(s: str) → bip.utils.site.Site¶
-
address
: bip.utils.site.Address¶
-
property
basic_information
¶
-
contacts
: List[bip.utils.site.Contact]¶
-
departments
: List[bip.utils.site.Department]¶
-
classmethod
-
class
bip.utils.site.
StaffMember
(role_name: «str», role_type: «str», person_name: «str», photo_url: «str» = '', phone: «str» = '', email: «str» = '')¶ Klasy bazowe:
object
-
property
basic_information
¶
-
property
-
bip.utils.site.
test_site
() → bip.utils.site.Site¶ Generate site data object for tests.
- Zwraca
site data object
- Typ zwracany
bip.utils.templates module¶
bip.utils.text module¶
-
bip.utils.text.
slugify
(text: str, delim: str = '-') → str¶ Create slug (url-safe ASCII representation) of given string.
bip.utils.views module¶
-
bip.utils.views.
is_redirect_safe
(target: Optional[str]) → bool¶ Check if redirect is safe, that is using HTTP protocol and is pointing to the same site.