permaculture package
Subpackages
Submodules
permaculture.action module
Action utilities.
- class permaculture.action.SingleAction(option_strings, dest, nargs=None, **kwargs)
Bases:
ActionArgparse action where nargs is not allowed.
- permaculture.action.enum_action(enum)
Return an argparse action class for an Enum type.
permaculture.cli module
Permaculture CLI.
- permaculture.cli.command_ingest(args, config)
Ingest plant data into local database.
- permaculture.cli.command_iterate(database)
Iterate over all scientific names.
- permaculture.cli.command_list(database)
List available ingestors.
- permaculture.cli.command_lookup(args, config, database)
Lookup characteristics by scientific name.
- permaculture.cli.command_search(args, database)
Search for the scientific name by common name.
- permaculture.cli.load_database(config)
Load the database from the configured storage.
- permaculture.cli.main(argv=None)
Entry point to the permaculture command.
- permaculture.cli.make_args_parser()
Make a parser for command-line arguments only.
- permaculture.cli.make_config_parser(config_files)
Make a parser for configuration files and command-line arguments.
permaculture.converter module
Converter base.
- class permaculture.converter.Converter(locales: Locales)
Bases:
object- convert(data)
- convert_bool(key, value)
- convert_float(key, value, unit=1.0)
- convert_ignore(*_)
- convert_int(key, value)
- convert_item(key, value)
- convert_letters(key, value)
Convert letters into a list of items.
The letters can be any unicode character and they can be followed by lowercase letters. The list might not be separated by punctuation or whitespace.
- convert_list(key, value, sep=',\\s*')
Convert a list of strings into a list of items.
The strings are separated by a comma optionally followed by whitespace.
- convert_range(key, value, unit=1.0)
- convert_string(key, value)
- convert_token(key, value)
- translate(message, context=None)
Convenience function to translate from locales.
permaculture.data module
Data manipulation functions.
Flattening nested data into flat data:
>>> flatten({'a': {'b': 1}})
{'a/b': 1}
Unflattening flat data into nested data:
>>> unflatten({'a/b': 1})
{'a': {'b': 1}}
Merging a list of dictionaries by calculating the mean on collision:
>>> merge([{'a': 1}, {'a': 2}], lambda _, v: sum(v)/len(v))
{'a': 1.5}
- permaculture.data.flatten(data, sep='/')
Flatten nested data into flat data.
- permaculture.data.merge(dicts, resolve=<function resolve>)
Merge a list of dictionaries by resolving collisions.
- Parameters:
resolve – Function called on collision to resolve colliding values.
- permaculture.data.resolve(key, values)
Default function to resolve collisions when merging dictionaries.
- permaculture.data.unflatten(data, sep='/')
Unflatten flat data into nested data.
permaculture.database module
Database utilities.
- class permaculture.database.Database(db_path)
Bases:
objectLocal SQLite database for plant records.
- db_path: Path
- classmethod from_storage(storage)
Create a Database from a storage provider.
- initialize()
Create tables and indexes.
- iterate() Iterator[DatabasePlant]
Iterate over all plants, merging across sources.
- lookup(names: list[str], score: float) Iterator[DatabasePlant]
Lookup characteristics by scientific names, merging across sources.
- search(name: str, score: float) Iterator[DatabasePlant]
Search for plants by name using FTS5 trigram matching.
- sources(include=None) list[str]
Return the distinct source names in the database.
- Parameters:
include – Optional regex to filter sources.
- write_batch(source, records)
Persist a batch of plant records.
- class permaculture.database.DatabasePlant(data: dict = _Nothing.NOTHING, weight: float = 1.0)
Bases:
MappingPlant record with structured data and weight.
- property common_names
- data: dict
- property names
- property scientific_name
- weight: float
- with_database(name)
Add the database name to this plant.
permaculture.de module
Design Ecologique database.
- class permaculture.de.DEConverter(locales: Locales = _Nothing.NOTHING)
Bases:
Converter- convert_bool(key, value)
Convert X to True, * to False, otherwise None.
- convert_item(key, value)
- convert_period(key, value)
- convert_range(key, value, unit=1.0)
- translate(message, context=None)
Translate * to None.
- class permaculture.de.DEIngestor(model: DEModel = _Nothing.NOTHING, priority: Priority = _Nothing.NOTHING)
Bases:
object- fetch_all()
- classmethod from_config(config)
Instantiate DEIngestor from config.
- class permaculture.de.DEModel(web: DEWeb = _Nothing.NOTHING, converter: DEConverter = _Nothing.NOTHING)
Bases:
object- converter: DEConverter
- get_perenial_plants()
- with_cache(storage)
- class permaculture.de.DEWeb(client: BrowserClient = _Nothing.NOTHING, storage: Storage = _NullStorage())
Bases:
objectDesign Ecologique web interface.
- client: BrowserClient
- perenial_plants_list()
List of perenial plants useful for permaculture in Quebec.
- Returns:
Google spreadsheet with plants.
- with_cache(storage)
permaculture.google module
Google spreadsheets web interface.
- class permaculture.google.GoogleSpreadsheet(session: HTTPSession, doc_id: str)
Bases:
objectGoogle spreadsheet.
- doc_id: str
- export(gid=1, fmt='csv')
- classmethod from_url(url: URL, storage=_NullStorage())
- session: HTTPSession
- sheets()
List sheets in the spreadsheet.
permaculture.http module
HTTP module.
- class permaculture.http.HTTPCache(storage: Storage = _Nothing.NOTHING)
Bases:
objectManages caching of responses according to RFC 2616.
- handle_304(response)
Given a 304 response, retrieve the cached entry.
- retrieve(request)
Retrieve a cached HTTP response if possible.
- store(response)
Store an HTTP response object in the cache.
- class permaculture.http.HTTPCacheAdapter(cache, **kwargs)
Bases:
HTTPAdapterAn HTTP cache adapter for Python requests.
- build_response(req, response)
Build a Response object from a urllib3 response.
- send(request, *args, **kwargs)
Send a PreparedRequest object respecting RFC 2616 rules about HTTP caching.
- class permaculture.http.HTTPCacheAll(storage: Storage = _Nothing.NOTHING)
Bases:
objectManages caching of all responses.
- handle_304(request)
Retrieve a cached HTTP response if possible.
- retrieve(request)
Retrieve a cached HTTP response if possible.
- store(response)
Store an HTTP response object in the cache.
- class permaculture.http.HTTPEntry(response: Response, creation: datetime, expiry: datetime | None = None)
Bases:
objectHTTP entry to cache in storage.
- creation: datetime
- expiry: datetime | None
- response: Response
- class permaculture.http.HTTPSession(origin, headers=None, **kwargs)
Bases:
SessionAn HTTP session with origin.
- request(method, path, **kwargs)
Send an HTTP request.
- Parameters:
method – Method for the request.
path – Path joined to the URL.
**kwargs – Optional keyword arguments passed to the session.
- with_adapter(http_adapter: HTTPAdapter, https_adapter: HTTPAdapter | None = None)
- with_cache(storage, cache_cls=<class 'permaculture.http.HTTPCacheAll'>, **kwargs)
- permaculture.http.parse_http_expiry(header, current_time)
Parse HTTP cache-control into the corresponding expiry time (in UTC).
- permaculture.http.parse_http_timestamp(header, default=None)
Parse an HTTP timestamp as RFC 2616.
permaculture.ingestor module
Ingestor protocol for fetching plant data from remote sources.
- class permaculture.ingestor.Ingestor(*args, **kwargs)
Bases:
ProtocolProtocol for fetching plant data from a remote source.
- fetch_all() Iterator[DatabasePlant]
Yield all plants from this source.
- classmethod from_config(config)
permaculture.ipinfo module
IP address information.
- class permaculture.ipinfo.IPinfo(session=_Nothing.NOTHING)
Bases:
object- json(ip=None)
Get information about an IP.
- Parameters:
ip – Optional IP address, defaults to your IP.
- point(ip=None)
Get the point for an IP.
- Parameters:
ip – Optional IP address, defaults to your IP.
- session
- with_cache(storage)
permaculture.location module
Location information.
A point has a latitude and a longitude:
>>> point = LocationPoint(0, 0)
>>> point
LocationPoint(lat=0.0, lon=0.0)
A polygon has many points that delimit a shape:
>>> poly = LocationPolygon.from_bbox(0, 0, 1, 1)
>>> poly.area
1.0
A multi polygon has many polygons that define many shapes:
>>> poly2 = LocationPolygon.from_bbox(1, 1, 3, 3)
>>> multi = LocationMultiPolygon.from_polygons([poly, poly2])
>>> multi.area
5.0
A point has a geographical distance to the nearest point on a polygon:
>>> poly.distance(point)
0
>>> poly2.distance(point)
157.24938127194397
A point also has a distance to the largest polygon, called the territory, in a multi polygon:
>>> multi.distance(point)
157.24938127194397
- class permaculture.location.LocationMultiPolygon(iterable=(), /)
Bases:
listA multi polygon.
- property area
Return the area of the multi polygon.
- distance(point)
Calculate the geographical distance to the territory.
- classmethod from_polygons(polygons)
- property territory
Return the polygon with the largest area.
- exception permaculture.location.LocationNotFound
Bases:
ExceptionRaised when a location is not found.
- class permaculture.location.LocationPoint(lat, lon)
Bases:
Sequence- distance(other)
Calculate the geographical distance between two points.
Uses the haversine formula to determine the great-circle distance.
- dot(other)
Dot product.
- classmethod from_point(point)
- lat: float
- lon: float
- property normsqr
Euclidean norm squared.
- slope(other)
Slope from this point to another point.
- class permaculture.location.LocationPolygon(iterable=(), /)
Bases:
LocationPolygonOrdering,listA polygon.
- property area
Return the area of the polygon.
- contains(point)
Return whether this polygon contains a point.
- distance(point)
Calculate the geographical distance to the nearest point.
- classmethod from_bbox(west, south, east, north)
- classmethod from_points(points)
Precalculate iedge vectors, for faster stable calculations
- nearest(point)
Return the nearest point on the perimeter of the polygon.
- property pairs
- class permaculture.location.LocationPolygonOrdering
Bases:
object
permaculture.logger module
Logger to setup logging for consistent messages.
The root logger can be setup like this which typically happens in the main entrypoint or in the lambda handler:
>>> logger = setup_logger()
>>> logger.name
'root'
The setup can also be parameterized with a custom log level or log handler:
>>> handler = LoggerHandlerAction.get_handler('-')
>>> logger = setup_logger(logging.DEBUG, handler)
The logger is typically instantiated with the name of the module at the top of source files:
>>> log = logging.getLogger(__name__)
Then, that logger is used inside functions and methods to log messages:
>>> from permaculture.testing.logger import logger_time
>>> with logger_time():
... log.info('created %(user)s', {'user': 'x'})
1970-01-01 00:00:00.000000 INFO permaculture.logger created x
It is also possible to add structured context information to the messages:
>>> with logger_context({'lambda': 'x'}), logger_time():
... log.warning('message')
1970-01-01 00:00:00.000000 WARNING permaculture.logger [{"lambda": "x"}] message
The LoggerLevelAction provides argument defaults for the log level:
>>> from argparse import ArgumentParser
>>> parser = ArgumentParser()
>>> action = parser.add_argument('--log-level', action=LoggerLevelAction)
>>> args = parser.parse_args(['--log-level', 'debug'])
>>> args.log_level == logging.DEBUG
True
The LoggerHandlerAction also provides argument defaults for the log handler:
>>> action = parser.add_argument('--log-file', action=LoggerHandlerAction)
>>> args = parser.parse_args(['--log-file', '-'])
>>> from logging import StreamHandler
>>> isinstance(args.log_file, StreamHandler)
True
The log level and log file can then be used to setup the root logger like this:
>>> logger = setup_logger(args.log_level, args.log_file)
- class permaculture.logger.JsonFormatter(fmt=None, datefmt=None)
Bases:
LoggerFormatterLogger formatter with sensible defaults.
- formatMessage(record)
- class permaculture.logger.LoggerFormatter(fmt=None, datefmt=None)
Bases:
FormatterLogger formatter with sensible defaults.
- converter(t)
- localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,
tm_sec,tm_wday,tm_yday,tm_isdst)
Convert seconds since the Epoch to a time tuple expressing local time. When ‘seconds’ is not passed in, convert the current time instead.
- formatTime(record, datefmt=None)
Format time with support for microseconds.
- class permaculture.logger.LoggerHandlerAction(option_strings, **kwargs)
Bases:
SingleActionArgument action for a logger handler.
Return a stream handler to stderr by default, a stream handler to stdout with ‘-’ or a file handler.
- classmethod get_handler(name=None)
Get a logger handler by name with a formatter.
- metavar = 'FILE'
- class permaculture.logger.LoggerLevelAction(option_strings, **kwargs)
Bases:
SingleActionArgument action for a logger level.
Return a numeric value for the log level.
- choices: ClassVar[list[str]] = ['debug', 'info', 'warning', 'error', 'critical']
- default: ClassVar[int] = 20
- metavar: ClassVar[str] = 'LEVEL'
- permaculture.logger.logger_context(ctx)
Context managed function to add log message context.
- permaculture.logger.remove_log_context(key)
Remove a log context from all log records.
- permaculture.logger.set_log_context(ctx)
Set context to all log records.
- permaculture.logger.setup_logger(level=20, handler=None, formatter=None, name=None)
Set a Logger instance with a handler.
permaculture.nc module
Natural Capital website.
- class permaculture.nc.NCAdapter(authentication, **kwargs)
Bases:
HTTPCacheAdapter- send(request, *args, **kwargs)
Send a PreparedRequest object respecting RFC 2616 rules about HTTP caching.
- class permaculture.nc.NCAuthentication(username: str, password: str, session: Session = _Nothing.NOTHING)
Bases:
object- authenticate(request)
- get_payload(request)
- password: str
- session: Session
- username: str
- exception permaculture.nc.NCAuthenticationError
Bases:
ExceptionRaised when authentication fails.
- class permaculture.nc.NCConverter(locales: Locales = _Nothing.NOTHING)
Bases:
Converter- convert_item(key, value)
- convert_period(key, value)
- convert_range(key, value, unit=1.0)
- convert_string(key, value)
- class permaculture.nc.NCIngestor(model: NCModel = _Nothing.NOTHING, priority: Priority = _Nothing.NOTHING)
Bases:
object- fetch_all()
- classmethod from_config(config)
Instantiate NCIngestor from config.
- class permaculture.nc.NCLink(text: str, url: str | SplitResult | URL | UndefinedType)
Bases:
object- property Id
- text: str
- url: URL
- class permaculture.nc.NCModel(web: NCWeb = _Nothing.NOTHING, converter: NCConverter = _Nothing.NOTHING)
Bases:
object- converter: NCConverter
- get_plant(Id)
Get plant details by Id.
- get_plant_total()
Get the total number of plants.
- get_plants(sci_name='', sort_name='', limit_start=0)
Get plants by scientific name or by common name.
- parse_detail(text)
Parse a plant detail consisting of an HTML table and paragraphs.
- parse_items(table)
Parse the items total inside a bold tag.
- parse_key_value(key_value)
Parse a bold key and roman value.
- parse_plant_list(text)
Parse a plant list consisting of an HTML table of plants.
- parse_plant_total(text)
Parse a plant list consisting of an HTML table of plants.
- parse_table(table)
Parse a table with a header into a list of dictionaries.
- parse_tr(row)
Parse a table row into an iterator of text or links.
- with_authentication(username: str, password: str, storage=_NullStorage())
Add authentication credentials to the model.
- class permaculture.nc.NCWeb(session: HTTPSession = _Nothing.NOTHING)
Bases:
object- session: HTTPSession
- view_detail(Id)
View plant detail.
- view_list(sci_name='', sort_name='', limit_start=0)
View plant list.
permaculture.nlp module
Natural language processing functions.
- class permaculture.nlp.Extractor(query, normalizer=<function Extractor.<lambda>>, scorer=<function Extractor.<lambda>>)
Bases:
object- choose(choices, default=None)
- extract(choices)
Extract the score for each choice.
- extract_one(choices)
Extract the beschoice with the best score.
- Raises:
ValueError – When there are no choices.
- property normalized_query
- normalizer
- query
- scorer
- permaculture.nlp.lev(s1, s2, sort=True)
Calculates the normalized Levenshtein distance between two strings.
- permaculture.nlp.normalize(text)
Transform text to a more consistent and simplified format.
- permaculture.nlp.score(s1, s2)
- permaculture.nlp.score_type(x)
Argument parser score type.
permaculture.nominatim module
Geocoding data from OpenStreetMap.
- class permaculture.nominatim.Nominatim(session=_Nothing.NOTHING)
Bases:
objectNominatim uses OpenStreetMap data to find locations on Earth.
- multi_polygon(query)
Get a multiple polygons around a place.
- point(query)
Get the point of a place.
- search(**params)
Search nominatim with the given params.
- session
- with_cache(storage)
permaculture.pfaf module
Plants For A Future database.
- class permaculture.pfaf.PFAFConverter(locales: Locales = _Nothing.NOTHING)
Bases:
Converter- convert_float(key, value)
- convert_item(key, value)
- class permaculture.pfaf.PFAFIngestor(model: PFAFModel, priority: Priority = _Nothing.NOTHING)
Bases:
object- fetch_all()
- classmethod from_config(config)
Instantiate PFAFIngestor from config.
- class permaculture.pfaf.PFAFModel(file: PFAFFile, converter: PFAFConverter = _Nothing.NOTHING)
Bases:
object- all_plants()
- converter: PFAFConverter
- classmethod from_path(path)
permaculture.priority module
Strategy for calculating the priority.
permaculture.registry module
Entry points based registry management.
- permaculture.registry.get_entry_points(group)
Get the list of pytest_unique entry points.
- permaculture.registry.registry_add(group, name, entry, registry=None)
Add an entry to a registry.
- Parameters:
group – Group of the entry.
name – Name of the entry.
entry – Entry to add.
registry – Optional registry to update.
- Returns:
A registry with the entry.
- permaculture.registry.registry_get(group, name, registry=None)
Get an entry from a registry.
If the registry is not defined or the group is not in the registry, the registry is loaded again.
- Parameters:
group – Group of the entry.
name – Name of the entry.
registry – Optional registry to get from.
- Raises:
KeyError – If not found.
- permaculture.registry.registry_load(name, registry=None)
Find all installed entry points.
- permaculture.registry.registry_remove(group, name, registry=None)
Remove an entry from a registry.
If the entry doesn’t exist, return silently.
- Parameters:
group – Group of the entry.
name – Name of the entry.
registry – Optional registry to update.
permaculture.runner module
Runner for orchestrating ingestion from sources into a database.
- class permaculture.runner.Runner(sources: dict[str, permaculture.ingestor.Ingestor] = _Nothing.NOTHING, database: Database = _Nothing.NOTHING, max_concurrency: int = 4, max_retries: int = 3, backoff_base: float = 0.25, backoff_cap: float = 10.0, batch_size: int = 500, queue_size: int = 5000)
Bases:
objectOrchestrates ingestion from multiple sources into a database.
Writes are serialized through a bounded async queue so that only one coroutine touches the database, avoiding SQLite lock errors.
- Parameters:
sources – Mapping of name to ingestor.
database – Destination database for plant records.
max_concurrency – Maximum parallel source ingestions.
max_retries – Maximum retry attempts per source.
backoff_base – Base for exponential backoff in seconds.
backoff_cap – Maximum backoff delay in seconds.
batch_size – Records per batch write.
queue_size – Maximum pending observations before backpressure.
- backoff_base: float
- backoff_cap: float
- batch_size: int
- max_concurrency: int
- max_retries: int
- queue_size: int
- run()
Run ingestion synchronously.
- sources: dict[str, permaculture.ingestor.Ingestor]
permaculture.sdp module
La Société des Plantes database.
- class permaculture.sdp.SDPConverter(locales: Locales = _Nothing.NOTHING)
Bases:
ConverterConverter for La Société des Plantes fields.
- convert_item(key, value)
- class permaculture.sdp.SDPIngestor(model: SDPModel = _Nothing.NOTHING, priority: Priority = _Nothing.NOTHING)
Bases:
objectIngestor for La Société des Plantes.
- fetch_all()
- classmethod from_config(config)
Instantiate SDPIngestor from config.
- class permaculture.sdp.SDPModel(web: SDPWeb = _Nothing.NOTHING, converter: SDPConverter = _Nothing.NOTHING)
Bases:
objectLa Société des Plantes model.
- all_plants()
Yield converted plant data for all products.
- converter: SDPConverter
- get_plant(path)
Fetch and parse a single product page.
- product_paths()
Return all French product paths from the sitemap.
- with_cache(storage)
- class permaculture.sdp.SDPWeb(session: HTTPSession = _Nothing.NOTHING)
Bases:
objectLa Société des Plantes web interface.
- product_page(path)
Fetch an individual product page.
- product_sitemap()
Fetch the product sitemap XML.
- session: HTTPSession
- with_cache(storage)
- permaculture.sdp.parse_family(text)
Extract the plant family from a description line.
>>> parse_family("Withania somnifera, Solanacées") 'solanacées' >>> parse_family("No match here")
- permaculture.sdp.parse_product(html)
Parse a product page and return a dict of raw fields.
Returns None for pages that don’t look like plant products.
- permaculture.sdp.parse_scientific_name(text)
Extract scientific name from a product description line.
The first line typically looks like: “Withania somnifera, Solanacées”
>>> parse_scientific_name("Withania somnifera, Solanacées") 'withania somnifera' >>> parse_scientific_name("Borago officinalis alba, Boraginacées") 'borago officinalis alba' >>> parse_scientific_name("No match here")
- permaculture.sdp.parse_sitemap_urls(xml_text)
Extract French product paths from the sitemap XML.
>>> urls = parse_sitemap_urls( ... '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' ... '<url><loc>https://www.lasocietedesplantes.com/produits/a/</loc></url>' ... '</urlset>' ... ) >>> urls ['/produits/a/']
permaculture.serializer module
Serializers for web related formats.
- class permaculture.serializer.Serializer(default_content_type: str, serializers: dict[str, 'SerializerPlugin'])
Bases:
objectA serializer to encode and decode data.
- Parameters:
content_type – Default content type of the serializer, defaults to application/json.
registry – Registry of serializers, defaults to the global registry.
- Raises:
SerializerNotFound – If the serializer is not found for the content type.
>>> serializer = Serializer.load() >>> serializer.encode('foo') == (b'"foo"', 'application/json', 'utf-8') True >>> serializer.decode(b'{"key": "value"}') == {'key': 'value'} True
- decode(payload, content_type=None)
Decode a payload based on a content type.
- Parameters:
content_type – Content type to override the default value.
charset – Character set of the payload.
- Returns:
The decoded data.
- Raises:
SerializerNotFound – If the serializer is not found for the content type or for the expected charset.
- default_content_type: str
- encode(data, content_type=None, optimize=False)
Encode data based on a content type.
- Parameters:
content_type – Content type to override the default value.
optimize – Optimize the content type for string types.
- Returns:
The encoded payload, content type and charset.
- Raises:
SerializerNotFound – If the serializer is not found for the content type.
- classmethod load(content_type='application/json', registry=None)
Load serializers from registry.
- class permaculture.serializer.SerializerAction(option_strings, registry=None, **kwargs)
Bases:
SingleActionArgument action for a serializer.
- classmethod get_serializer(content_type)
Get a serializer with a default content-type.
- metavar = 'CONTENT-TYPE'
- exception permaculture.serializer.SerializerNotFound
Bases:
ExceptionRaised when a serializer is not found for a content type.
- class permaculture.serializer.SerializerPlugin(encode: Callable[[Any], bytes], decode: Callable[[bytes], Any], charset: str)
Bases:
objectSerializer with an encode/decode method definable inline.
- charset: str
- decode: Callable[[bytes], Any]
- encode: Callable[[Any], bytes]
- permaculture.serializer.json_serializer = SerializerPlugin(encode=<function <lambda>>, decode=<function <lambda>>, charset='utf-8')
Serializer for application/json.
- permaculture.serializer.octet_stream_serializer = SerializerPlugin(encode=<function <lambda>>, decode=<function <lambda>>, charset='binary')
Serializer for application/octet-stream.
This serializer doesn’t do anything.
- permaculture.serializer.pickle_serializer = SerializerPlugin(encode=<built-in function dumps>, decode=<built-in function loads>, charset='binary')
Serializer for application/x-pickle.
- permaculture.serializer.text_csv_serializer = SerializerPlugin(encode=<function _text_csv_serializer_encode>, decode=<function _text_csv_serializer_decode>, charset='utf-8')
Serializer for text/csv.
- permaculture.serializer.text_plain_serializer = SerializerPlugin(encode=<function _text_plain_serializer_encode>, decode=<function _text_plain_serializer_decode>, charset='utf-8')
Serializer for text/plain.
- permaculture.serializer.www_form_serializer = SerializerPlugin(encode=<function <lambda>>, decode=<function <lambda>>, charset='utf-8')
Serializer for application/x-www-form-urlencoded.
- permaculture.serializer.yaml_serializer = SerializerPlugin(encode=<function <lambda>>, decode=<function <lambda>>, charset='utf-8')
Serializer for application/x-yaml.
permaculture.storage module
Storage providers.
- class permaculture.storage.FileStorage(base_dir, serializer='application/x-pickle')
Bases:
StorageFile storage.
- Parameters:
base_dir – Base directory for storing files.
serializer – Serializer, defaults to application/x-pickle.
- base_dir: Path
- key_to_path(key)
- path_to_key(path)
- serializer: Serializer
- class permaculture.storage.SqliteStorage(conn, serializer='application/x-pickle')
Bases:
StorageSqlite storage.
- Parameters:
path – Path to SQLite database.
serializer – Serializer, defaults to application/x-pickle.
- conn
- classmethod from_path(path)
- serializer: Serializer
- class permaculture.storage.StorageAction(option_strings, registry=None, **kwargs)
Bases:
SingleActionArgument action for storage.
- classmethod get_storage(path)
Get storage with a default path.
- metavar = 'PATH'
- permaculture.storage.hash_request(method, url, body=None)
Hash an HTTP-like request into a storage key.
permaculture.unit module
Unit functions.
permaculture.usda module
USDA Plants database.
- class permaculture.usda.USDAConverter(locales: Locales = _Nothing.NOTHING)
Bases:
Converter- convert_item(key, value)
- class permaculture.usda.USDAIngestor(model: USDAModel = _Nothing.NOTHING, priority: Priority = _Nothing.NOTHING)
Bases:
object- fetch_all()
- classmethod from_config(config)
Instantiate USDAIngestor from config.
- class permaculture.usda.USDAModel(web: USDAWeb = _Nothing.NOTHING, converter: USDAConverter = _Nothing.NOTHING)
Bases:
objectUSDA Plants model.
- all_characteristics()
Return the characteristics for all plants.
- converter: USDAConverter
- plant_characteristics(plant)
Return the characteristics for a single plant.
- plant_search(text, field)
- with_cache(storage)
- class permaculture.usda.USDAWeb(session: HTTPSession = _Nothing.NOTHING)
Bases:
objectUSDA Plants web interface.
- characteristics_search(**kwargs)
Search characteristics.
- plant_characteristics(Id)
Plant characteristics for an identifier.
- plant_profile(symbol)
Plant profile for a symbol.
- plant_search(**kwargs)
Search plants.
- session: HTTPSession