Skip to main content

MorfDict

MorfDict is a dict like object, which convers data late on the fly.

>> from morfdict import MorfDict
>> data = MorfDict()
>> data['first'] = 'my data'
>> data['first']
'my data'
>> data.set_morf('first', lambda obj, value: '*' + value + '*')
>> data['first']
'*my data*'

If you want to make your own default morf method, just ovveride _default_morf method.

>> class MyMorf(MorfDict):
>>    def _default_morf(self, obj, value):
>>        return '*' + value + '*'

StringDict class

StringDict is MorfDict whith default interpolation for itself.

>> from morfdict import StringDict
>> data = StringDict()
>> data['first'] = 'one'
>> data['second'] = '%(first)s two'
>> data['second']
'one two'

PathDict class

PathDict is designed for storing paths.

>> from morfdict import PathDict
>> paths = PathDict({'base' : '/tmp'})
>> paths['home'] = ['%(base)s', 'home', 'myname']
>> paths['home']
'/tmp/home/myname'

Or you can make this:

>> from morfdict import PathDict
>> paths = PathDict({'base' : '/tmp'})
>> paths.set_path('main', 'base', 'home')
>> paths.set_path('home', 'main', 'myname')
>> paths['home']
'/tmp/home/myname'

Factory class

If we want to use ‘modulename.settings’ where ‘modulename’ is our main module and ‘settings’ is our settins module.

>> from morfdict import Factory
>> factory = Factory('modulename', 'settings')
>> settings, paths = factory.make_settings()

It will read the settings from modulename/settings/default.py. This file should looks like this:

>> def make_settings(settings, paths):
>>     settings['name'] = 'value'

If we want to add some additional files for settings, like “local.py”, we can do this:

>> settings, paths = factory.make_settings(additional_modules=[('local', False)])

This is the default behavior. The bool means “raise error on missing module”.

Metadata

Release files for MorfDict 0.4.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for MorfDict 0.4.7
File Size Uploaded
MorfDict-0.4.7.tar.gz 16.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for MorfDict 0.4.7
File Interpreter ABI Platform
MorfDict-0.4.7-py3-none-any.whl Python 3 none any Details

Total release size: 28.1 kB

Release files / MorfDict-0.4.7.tar.gz

Download URL MorfDict-0.4.7.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
70ffb419e6b615fcebce45b6783ef4272a5eb88818ebbeda7dd18e3eae1e4199
BLAKE2b-256 checksum
How to use checksums
7e77d606e30e0b4ba143530ace8607e8a7dbf6cd2f7b84c95dd0be1c6ac2a2ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / MorfDict-0.4.7-py3-none-any.whl

Download URL MorfDict-0.4.7-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8fd827da87a2577402dc87b87c64a39d54f02418103380b4b098bb80cb75bc84
BLAKE2b-256 checksum
How to use checksums
171db1802fd925a11b2f26661d748305006e94b5e0e315b0cdf8b8944cf3bb79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.4.7 This release

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.7

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page