Skip to content

Commit

Permalink
write: end
Browse files Browse the repository at this point in the history
  • Loading branch information
CavalcanteLucas committed Jun 28, 2022
1 parent add6778 commit 86132c7
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 131 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Reference: https://github.com/fluentpython/example-code-2e/blob/master/22-dyn-attr-prop/oscon/test_schedule_v1.py

import pytest

import ex_19_9__schedule1 as schedule


@pytest.fixture
def records():
yield schedule.load(schedule.JSON_PATH)


def test_load(records):
assert len(records) == 895


def test_record_attr_access():
rec = schedule.Record(spam=99, eggs=12)
assert rec.spam == 99
assert rec.eggs == 12


def test_venue_record(records):
venue = records['venue.1469']
assert venue.serial == 1469
assert venue.name == 'Exhibit Hall C'
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import ex_21_15__model_v7 as model


class LineItem(model.Entity):
description = model.NonBlank()
weight = model.Quantity()
price = model.Quantity()

def __init__(self, description, weight, price):
self.description = description
self.weight = weight
self.price = price

def subtotal(self):
return self.weight * self.price
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import setup
from Chap_20__Attribute_Descriptors.ex_20_6__model_v5 import (
Quantity,
NonBlank,
Validated,
)


class EntityMeta(type):
"""Metaclass for business entities with validated fields"""

def __init__(cls, name, bases, attr_dict):
super().__init__(name, bases, attr_dict)
for key, attr in attr_dict.items():
if isinstance(attr, Validated):
type_name = type(attr).__name__
attr.storage_name = '_{}#{}'.format(type_name, key)


class Entity(metaclass=EntityMeta):
"""Business entity with validated fields"""
170 changes: 45 additions & 125 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,133 +1,53 @@
appdirs==1.4.4
apturl==0.5.2
argon2-cffi==20.1.0
async-generator==1.10
attrs==20.3.0
aiohttp==3.8.1
aiosignal==1.2.0
asttokens==2.0.5
async-timeout==4.0.2
attrs==21.4.0
backcall==0.2.0
bcrypt==3.1.7
black==21.7b0
bleach==3.3.0
blinker==1.4
blue==0.7.0
bobo==2.4.0
Brlapi==0.7.0
certifi==2019.11.28
cffi==1.14.5
chardet==3.0.4
click==8.0.1
colorama==0.4.3
command-not-found==0.3
cryptography==3.3.2
cupshelpers==1.0
dbus-python==1.2.16
decorator==4.4.2
defer==1.0.6
defusedxml==0.6.0
distro==1.4.0
distro-info===0.23ubuntu1
duplicity==0.8.12.0
entrypoints==0.3
fasteners==0.14.1
flake8==3.8.4
future==0.18.2
Guake==3.8.5
httplib2==0.19.0
idna==2.8
ipykernel==5.5.0
ipython==7.31.1
ipython-genutils==0.2.0
ipywidgets==7.6.3
isodate==0.6.0
jedi==0.18.0
Jinja2==2.11.3
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==6.1.11
jupyter-console==6.2.0
jupyter-core==4.7.1
jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.0
keyring==18.0.1
language-selector==0.1
launchpadlib==1.10.13
lazr.restfulclient==0.14.2
lazr.uri==1.0.3
lockfile==0.12.2
louis==3.12.0
macaroonbakery==1.3.1
Mako==1.1.0
MarkupSafe==1.1.1
mccabe==0.6.1
mistune==0.8.4
monotonic==1.5
black==22.1.0
certifi==2022.5.18.1
charset-normalizer==2.0.12
click==8.0.3
debugpy==1.5.1
decorator==5.1.1
entrypoints==0.4
executing==0.8.2
frozenlist==1.3.0
idna==3.3
iniconfig==1.1.1
ipykernel==6.9.1
ipython==8.0.1
jedi==0.18.1
jupyter-client==7.1.2
jupyter-core==4.9.2
matplotlib-inline==0.1.3
multidict==6.0.2
mypy-extensions==0.4.3
nbclient==0.5.2
nbconvert==6.0.7
nbformat==5.1.2
nest-asyncio==1.5.1
netifaces==0.10.4
notebook==6.4.10
numpy==1.21.0
oauthlib==3.1.0
olefile==0.46
packaging==20.9
pandocfilters==1.4.3
paramiko==2.10.1
parso==0.8.1
nest-asyncio==1.5.4
packaging==21.3
parso==0.8.3
pathspec==0.9.0
pbr==5.4.5
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.0.1
prometheus-client==0.9.0
prompt-toolkit==3.0.16
protobuf==3.15.0
platformdirs==2.5.0
pluggy==1.0.0
prompt-toolkit==3.0.28
ptyprocess==0.7.0
pycairo==1.16.2
pycodestyle==2.6.0
pycparser==2.20
pycups==1.9.73
pyflakes==2.2.0
Pygments==2.8.0
PyGObject==3.36.0
PyJWT==2.4.0
pymacaroons==0.13.0
PyNaCl==1.3.0
pyparsing==2.4.7
pyRFC3339==1.1
pyrsistent==0.17.3
python-apt==2.0.0+ubuntu0.20.4.7
python-dateutil==2.8.1
python-debian===0.1.36ubuntu1
pytz==2019.3
pyxdg==0.26
PyYAML==5.4
pyzmq==22.0.3
qtconsole==5.0.2
QtPy==1.9.0
regex==2021.9.24
reportlab==3.5.55
requests==2.22.0
requests-unixsocket==0.2.0
SecretStorage==2.3.1
Send2Trash==1.5.0
simplejson==3.16.0
six==1.15.0
systemd-python==234
terminado==0.9.2
testpath==0.4.4
tomli==1.2.1
pure-eval==0.2.2
py==1.11.0
Pygments==2.11.2
pyparsing==3.0.9
pytest==7.1.2
python-dateutil==2.8.2
pyzmq==22.3.0
repackage==0.7.3
requests==2.28.0
six==1.16.0
stack-data==0.2.0
tomli==2.0.1
tornado==6.1
traitlets==5.0.5
ubuntu-advantage-tools==27.6
ubuntu-drivers-common==0.0.0
ufw==0.36
unattended-upgrades==0.1
urllib3==1.26.5
usb-creator==0.3.7
wadllib==1.3.3
tqdm==4.64.0
traitlets==5.1.1
urllib3==1.26.9
wcwidth==0.2.5
webencodings==0.5.1
WebOb==1.8.7
widgetsnbextension==3.5.1
xkit==0.0.0
yarl==1.7.2

0 comments on commit 86132c7

Please sign in to comment.