lawwenda package¶
Subpackages¶
Submodules¶
lawwenda.comm module¶
Internal communication helpers.
-
class
lawwenda.comm.
JsonedResponse
(data, **kwargs)¶ Bases:
werkzeug.wrappers.response.Response
A werkzeug response that serializes response data to json.
- Parameters
data (Optional[Any]) – Response data. Can be anything that json is able to serialize.
-
class
lawwenda.comm.
Request
(environ, populate_request=True, shallow=False)¶ Bases:
werkzeug.wrappers.request.Request
,werkzeug.wrappers.json.JSONMixin
A werkzeug request that is able to interpret json data in the response body.
lawwenda.datafiles module¶
Paths to some files and directories of Lawwenda.
-
lawwenda.datafiles.
find_data_file
(fname, searchdirs=None)¶ Return the absolute path of a Lawwenda data file.
Can return None if no such file exists.
- Parameters
fname (str) – The name of the file to find.
searchdirs (Optional[Iterable[str]]) – List of directories to look into. If not specified (as it usually should be), it looks at some usual places.
- Return type
Optional[str]
lawwenda.devserver module¶
Tiny local server for trying, development, testing.
-
class
lawwenda.devserver.
_DevServerInfo
(svr, svrthread)¶ Bases:
object
-
shutdown
()¶ Stop this server.
- Return type
None
-
property
url
¶ The url of this running server.
- Return type
str
-
wait_stopped
()¶ Wait until this server stopped.
- Return type
None
-
-
class
lawwenda.devserver.
_DevServerThread
(svr)¶ Bases:
threading.Thread
This constructor should always be called with keyword arguments. Arguments are:
group should be None; reserved for future extension when a ThreadGroup class is implemented.
target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.
args is the argument tuple for the target invocation. Defaults to ().
kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.
-
run
()¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
-
-
lawwenda.devserver.
_run_dev_server_for_app
(app)¶ Start a tiny local server for a given wsgi application.
- Parameters
app (Callable) – The wsgi application to run.
- Return type
-
lawwenda.devserver.
get_running_dev_servers
()¶ Return the servers started by
run_dev_server()
that are currently running.- Return type
Iterable[lawwenda.devserver._DevServerInfo]
-
lawwenda.devserver.
run_dev_server
(cfg)¶ Start a tiny local server for a given configuration.
Such a server can be used for trying, development, testing, and so on, but is not recommended for real usage.
It will automatically find a free port and will return a control object that contains the full url, and more.
- Parameters
cfg (lawwenda.Configuration) – The configuration to run with.
- Return type
lawwenda.fmapp module¶
A wsgi application that provides a browser based user interface, similar to a desktop file manager.
See FmApp
.
-
class
lawwenda.fmapp.
FmApp
(share)¶ Bases:
object
A wsgi application that provides a browser based user interface, similar to a desktop file manager.
- Parameters
share (lawwenda.Share) – The share to provide by this application.
-
URL_INTERNALS_NAME
= '.~__lawwenda__int~'¶
-
__auth
(username, password)¶ - Parameters
username (str) –
password (str) –
- Return type
bool
-
__dispatch_request
(request)¶
-
__dispatch_request_internals
(request)¶
-
__dispatch_request_normal
(request)¶
-
__ensure_authed
(request)¶
-
__on_api_copymove
(request, action)¶
-
__render_template
(template, *, html_head_inner='', path='', headonly=False, url_internals_name='.~__lawwenda__int~', **kwargs)¶ - Parameters
template (str) –
html_head_inner (str) –
path (str) –
headonly (bool) –
url_internals_name (str) –
- Return type
werkzeug.wrappers.response.Response
-
__render_template_text
(template, *, csrftoken, html_head_inner, **kwargs)¶ - Parameters
template (str) –
csrftoken (str) –
html_head_inner (str) –
- Return type
str
-
__render_template_text_raw
(template, **kwargs)¶ - Parameters
template (str) –
- Return type
str
-
_on_api_copy
(request)¶
-
_on_api_delete
(request)¶
-
_on_api_details
(request)¶
-
_on_api_dir
(request)¶
-
_on_api_mkdir
(request)¶
-
_on_api_move
(request)¶
-
_on_api_rename
(request)¶
-
_on_api_set_comment
(request)¶
-
_on_api_set_geo
(request)¶
-
_on_api_set_rating
(request)¶
-
_on_api_tag_entries
(request)¶
-
_on_api_thumbnail
(request)¶
-
_on_api_untag_entries
(request)¶
-
_on_api_upload
(request)¶
-
_on_api_zip
(request)¶
-
_on_api_zip_download
(request, zipid)¶
-
_on_help
(_)¶
-
_on_static
(_, filepath)¶
-
property
filesystem
¶ The filesystem used by this FmApp.
- Return type
-
class
lawwenda.fmapp.
_RenderTemplateValue
(s)¶ Bases:
object
String representation for usage in template rendering.
Usually an html escaped variant of the input string, but with an option to also get the unescaped string.
-
property
unescaped
¶ The unescaped string.
-
property
-
class
lawwenda.fmapp.
_TempZips
¶ Bases:
object
Handler for temporary zip files.
Allows to create zip files containing some nodes and automatically cleans them up after some time.
This is a static class, potentially used by many applications in parallel.
-
class
_TempZip
(nodes)¶ Bases:
object
A temporary zip file.
- Parameters
nodes (List[lawwenda.fs.Filesystem.Node]) –
-
static
_TempZip__is_executable
(node)¶ - Parameters
node (lawwenda.fs.Filesystem.Node) –
- Return type
bool
-
_TempZip__putnode
(node, zipf)¶ - Parameters
node (lawwenda.fs.Filesystem.Node) –
zipf (zipfile.ZipFile) –
- Return type
None
-
property
bytes
¶ The binary representation of this temporary zip archive.
-
classmethod
_TempZips__cleanup_loop
()¶
-
_cleanup_thread
= None¶
-
_lock
= <unlocked _thread.lock object>¶
-
_zips
= {}¶
-
classmethod
create_tempzip
(owner, nodes)¶ Create a temporary zip archive from some nodes in memory and return an identifier.
See also
get_tempzip()
.- Parameters
owner (object) – Request owner. Can be an arbitrary object (but must be equal for all calls that belong together).
nodes (List[lawwenda.fs.Filesystem.Node]) – The nodes to include in the zip archive.
- Return type
str
-
classmethod
get_tempzip
(owner, zipid)¶ Return the binary content of a zip archive that was created before by
create_tempzip()
.- Parameters
owner (object) – Request owner. Can be an arbitrary object (but must be equal for all calls that belong together).
zipid (str) – The identifier returned by create_tempzip.
- Return type
Optional[bytes]
-
class
lawwenda.lawwenda_cli module¶
The Lawwenda command line interface.
This tool is used by the end user for creating and managing shares and more. It can be called with some command line arguments for a particular action, or without parameters (which will open an interactive Python prompt for further actions).
Do not use this module in code. See lawwenda.Configuration
instead.
-
lawwenda.lawwenda_cli.
_fmt_cmd
(txt)¶ - Parameters
txt (str) –
- Return type
str
-
lawwenda.lawwenda_cli.
_quickstart
(cfgpath)¶ - Parameters
cfgpath (str) –
- Return type
str
Add a share.
Only used internally by the cli. See
lawwenda.Configuration.add_share()
.- Parameters
cfg (lawwenda.Configuration) –
name (str) –
path (str) –
title (str) –
active_until (str) –
hide_by_pattern (List[str]) –
hide_by_tag (List[str]) –
include_by_pattern (List[str]) –
include_by_tag (List[str]) –
exclude_by_pattern (List[str]) –
exclude_by_tag (List[str]) –
exclude_hidden (bool) –
readonly (bool) –
- Return type
None
-
lawwenda.lawwenda_cli.
console
(*, cfg)¶ Open an interactive Python console.
The user will get a small help text and is then able to configure Lawwenda by typing Python code.
- Parameters
cfg (lawwenda.Configuration) – The initial value for the cfg variable inside the console.
- Return type
None
Return a textual share description (i.e. how it is configured) for a share.
Only used internally by the cli. See
lawwenda.Configuration
.- Parameters
cfg (lawwenda.Configuration) –
name (str) –
- Return type
str
-
lawwenda.lawwenda_cli.
generate_wsgi
(*, cfg)¶ Generates a wsgi script for hosting Lawwenda in a web server.
Only used internally by the cli. See
lawwenda.Configuration.generate_wsgi()
.- Parameters
cfg (lawwenda.Configuration) –
- Return type
str
Return a list of share names as string, one line for each share.
Only used internally by the cli. See
lawwenda.Configuration
.- Parameters
cfg (lawwenda.Configuration) –
- Return type
str
-
lawwenda.lawwenda_cli.
main
()¶ Parse command line arguments and call the right function with its arguments.
Remove a share.
Only used internally by the cli. See
lawwenda.Configuration.remove_share()
.- Parameters
cfg (lawwenda.Configuration) –
name (str) –
- Return type
None
-
lawwenda.lawwenda_cli.
run_dev_server
(*, cfg)¶ Start a tiny local server for this configuration.
Such a server can be used for trying, development, testing, and so on, but is not recommended for real usage.
It will automatically find a free port, will print its url, and blocks.
Only used internally by the cli. See
lawwenda.Configuration
.- Parameters
cfg (lawwenda.Configuration) –
- Return type
None
lawwenda.mainapp module¶
TODO.
-
class
lawwenda.mainapp.
MainApp
(*, cfgpath=None)¶ Bases:
object
TODO.
- Parameters
cfgpath (Optional[str]) – TODO.
Bases:
object
Container for one
lawwenda.fmapp.FmApp
and its associatedlawwenda.Share
.- Parameters
share (lawwenda.Share) –
The application.
- Return type
Whether this share is still active (not yet removed).
- Return type
bool
- Parameters
sharename (str) –
Module contents¶
User side API for reading and modifying Lawwenda configurations, creating shares, and more.
For most cases, instantiate Configuration
and use some if its methods.
-
class
lawwenda.
Configuration
(cfgpath=None)¶ Bases:
object
TODO.
- Parameters
cfgpath (Optional[str]) – The path of the configuration directory. Will be created on demand if it does not exist. Defaults to a location that is usual for your operating system.
-
__verify_valid_name
()¶ - Parameters
name (str) –
- Return type
None
Add a new share.
- Parameters
path (str) – The directory to share. See
Share.path
.name (str) – The unique name of the new share. See
Share.name
.password (Optional[str]) – The password to protect the share with.
title (Optional[str]) – The share title. See
Share.title
.readonly (bool) – If to share in a read-only way. See
Share.readonly
.hide_by_patterns (Iterable[str]) – See
Share.hide_by_patterns
.hide_by_tags (Iterable[str]) – See
Share.hide_by_tags
.include_by_patterns (Optional[Iterable[str]]) – See
Share.include_by_patterns
.include_by_tags (Optional[Iterable[str]]) – See
Share.include_by_tags
.exclude_by_patterns (Iterable[str]) – See
Share.exclude_by_patterns
.exclude_by_tags (Iterable[str]) – See
Share.exclude_by_tags
.exclude_hidden (bool) – See
Share.exclude_hidden
.active_until (Optional[datetime.datetime]) – The optional expiration time of the share. See
Share.active_until
.
- Return type
-
generate_wsgi
()¶ Generates a wsgi script for hosting Lawwenda in a web server.
Read the ‘Installation’ section of the documentation for more details about what to do with it.
- Return type
str
Return the share by a name (or None if it does not exist).
- Parameters
name (str) –
- Return type
Optional[lawwenda.Share]
Return all shares that are currently part of this configuration.
- Return type
List[lawwenda.Share]
-
property
path
¶ The path of the configuration directory.
- Return type
str
TODO.
- Parameters
name (str) – The share name.
- Return type
Optional[object]
Remove a share.
- Parameters
name (str) – The name of the share to remove.
- Return type
None
-
run_dev_server
()¶ Start a tiny local server for this configuration.
Such a server can be used for trying, development, testing, and so on, but is not recommended for real usage.
It will automatically find a free port and will return a control object that contains the full url, and more.
- Return type
Bases:
object
A directory path together with some parameters (e.g. for access control) for sharing via Lawwenda. Read the documentation for more about shares.
This class is not intended to be instantiated directly. You will get instances by some other api methods.
- Parameters
path (str) –
configuration (Configuration) –
name (str) –
title (str) –
cachetag (object) –
readonly (bool) –
hide_by_patterns (Iterable[str]) –
hide_by_tags (Iterable[str]) –
include_by_patterns (Optional[Iterable[str]]) –
include_by_tags (Optional[Iterable[str]]) –
exclude_by_patterns (Iterable[str]) –
exclude_by_tags (Iterable[str]) –
exclude_hidden (bool) –
password_scrypt (Optional[str]) –
password_salt (Optional[str]) –
active_until_timestamp (Optional[float]) –
The expiration time of this share, or None for infinite.
- Return type
t.Optional[datetime.datetime]
Same as
active_until
, but as Unix timestamp.- Return type
t.Optional[float]
The configuration that contains this share.
- Return type
A list of regular expressions of paths for excluding.
A file or directory will be excluded if its path matches at least one of them. Those paths are always relative to
path
, always start with a ‘/’, but never end with a one (unless it is the root path).Exclusions are enforced on backend side and not just a presentation aspect. There is no way for a client to work around that (unless there is a software bug).
- Return type
t.Iterable[str]
A list of tags for excluding files and directories.
Exclusions are enforced on backend side and not just a presentation aspect. There is no way for a client to work around that (unless there is a software bug).
- Return type
t.Iterable[str]
If to consider ‘hidden’ flags of files or directories as exclusions.
Exclusions are enforced on backend side and not just a presentation aspect. There is no way for a client to work around that (unless there is a software bug).
- Return type
bool
A list of regular expressions of paths for hiding.
A file or directory will be hidden if its path matches at least one of them. Those paths are always relative to
path
, always start with a ‘/’, but never end with a one (unless it is the root path).Note that hiding is not a security feature unless
exclude_hidden
is set.- Return type
t.Iterable[str]
A list of tags for hiding files and directories.
A file or directory will be hidden if it is tagged with at least one of them.
Note that hiding is not a security feature unless
exclude_hidden
is set.- Return type
t.Iterable[str]
A list of regular expressions of paths for including explicitly.
Those paths are always relative to
path
, always start with a ‘/’, but never end with a one (unless it is the root path).If this is specified, the share will switch from blacklist to whitelist. Everything that is not considered as included is implicitly considered as excluded.
- Return type
t.Optional[t.Iterable[str]]
A list of tags for including files and directories.
If this is specified, the share will switch from blacklist to whitelist. Everything that is not considered as included is implicitly considered as excluded.
- Return type
t.Optional[t.Iterable[str]]
If this share is currently active (e.g. not yet expired; see
active_until
).- Return type
bool
If this share is expired.
- Return type
bool
The share name.
This usually makes the last part of the url to this share. Is unique in the containing
configuration
.- Return type
str
The hash salt of the password for this share, if password protected.
See also
password_scrypt
.- Return type
t.Optional[str]
The scrypt hash of the password for this share.
Empty or None for disabled password protection. See also
password_salt
.- Return type
t.Optional[str]
The path of the share’s root directory.
- Return type
str
If this share is restricted to only read actions (no removal, copying, uploading, editing, … of the files and directories in
path
).- Return type
bool
The share title.
This is an arbitrary text shown in the window title. Should not contain line breaks and should be short.
- Return type
str