-
Notifications
You must be signed in to change notification settings - Fork 5
Making it run again #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
6e94032
3e0ea29
b69be26
48a48ac
784db4f
1126c19
254f2b2
76f7d34
ec142fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| *.egg-info/* | ||
| .coverage | ||
| __pycache__ | ||
| assets/ | ||
| bin/ | ||
| contracts/ | ||
| docs/_build/ | ||
| invoices/ | ||
| lib* | ||
| pyvenv.cfg | ||
| settings.yaml | ||
| share/ | ||
| ./assets/ | ||
| ./contracts/ | ||
| ./invoices/ | ||
| ./settings.yaml | ||
| docs/_build/ | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,8 +19,12 @@ def get_contracts(settings, year=None, month=None, cid_only=None, inactive=False | |||||||||||
| if cid_only and cid_only != filename.stem: | ||||||||||||
| continue | ||||||||||||
|
|
||||||||||||
| with open(Path(settings.contracts_dir / filename), "r") as contract_file: | ||||||||||||
| contract = yaml.safe_load(contract_file) | ||||||||||||
| contract = yaml.safe_load( | ||||||||||||
| (settings.contracts_dir / filename).read_text("utf-8") | ||||||||||||
| ) | ||||||||||||
|
Comment on lines
+22
to
+24
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reading everything into a buffer to then passing it to Instead of using the
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After all I think the encoding was partly a problem on my side. I think some Python files where for whatever reason in a different encoding causing a lot of trouble. Should I fix this particular issue or should I revert it? |
||||||||||||
|
|
||||||||||||
| if not contract.get("active", True): | ||||||||||||
| continue | ||||||||||||
|
|
||||||||||||
| if year and month: | ||||||||||||
| requested_date = arrow.get(f"{year}-{month:02}") | ||||||||||||
|
|
@@ -48,9 +52,7 @@ def render_contracts(settings): | |||||||||||
| for contract_filename in Path(settings.contracts_dir).glob("*.yaml"): | ||||||||||||
| contract_pdf_filename = "{}.pdf".format(str(contract_filename).split(".")[0]) | ||||||||||||
| if not Path(contract_pdf_filename).is_file(): | ||||||||||||
|
|
||||||||||||
| with open(contract_filename) as yaml_file: | ||||||||||||
| contract_data = yaml.safe_load(yaml_file) | ||||||||||||
| contract_data = yaml.safe_load(contract_filename.read_text("utf-8")) | ||||||||||||
| print("Rendering contract pdf for {}".format(contract_data["cid"])) | ||||||||||||
| contract_data.update(settings._asdict()) | ||||||||||||
|
|
||||||||||||
|
|
@@ -87,47 +89,48 @@ def send_contract(settings, cid): | |||||||||||
| if not contract_pdf_path.is_file(): | ||||||||||||
| print(f"Contract {cid} not found") | ||||||||||||
|
|
||||||||||||
| with open(contract_yaml_filename) as yaml_file: | ||||||||||||
| contract_data = yaml.safe_load(yaml_file) | ||||||||||||
|
|
||||||||||||
| if contract_data["email"] is None: | ||||||||||||
| print("No email given for contract {cid}") | ||||||||||||
| quit() | ||||||||||||
|
|
||||||||||||
| contract_pdf_filename = f"{settings.company_name} {contract_yaml_filename.stem}.pdf" | ||||||||||||
| contract_mail_text = mail_template.render() | ||||||||||||
|
|
||||||||||||
| attachments = [(contract_pdf_path, contract_pdf_filename)] | ||||||||||||
|
|
||||||||||||
| for item in contract_data["items"]: | ||||||||||||
| item_pdf_file = f"{item['description']}.pdf" | ||||||||||||
| item_pdf_path = Path(settings.assets_dir / item_pdf_file) | ||||||||||||
| if item_pdf_path.is_file(): | ||||||||||||
| attachments.append((item_pdf_path, item_pdf_file)) | ||||||||||||
| else: | ||||||||||||
| print(f"Item file {item_pdf_file} not found") | ||||||||||||
|
|
||||||||||||
| if settings.policy_attachment_asset_file: | ||||||||||||
| policy_pdf_path = settings.policy_attachment_asset_file | ||||||||||||
| if policy_pdf_path.is_file(): | ||||||||||||
| attachments.append((policy_pdf_path, policy_pdf_path.name)) | ||||||||||||
| else: | ||||||||||||
| print(f"Missing {settings.policy_attachment_asset_file.name}") | ||||||||||||
|
|
||||||||||||
| contract_email = generate_email( | ||||||||||||
| settings, | ||||||||||||
| contract_data["email"], | ||||||||||||
| settings.contract_mail_subject, | ||||||||||||
| contract_mail_text, | ||||||||||||
| attachments, | ||||||||||||
| ) | ||||||||||||
| contract_data = yaml.safe_load(contract_yaml_filename.read_text("utf-8")) | ||||||||||||
|
|
||||||||||||
| print("Sending contract {}".format(contract_data["cid"])) | ||||||||||||
| if contract_data["email"] is None: | ||||||||||||
| print("No email given for contract {cid}") | ||||||||||||
| quit() | ||||||||||||
|
|
||||||||||||
| send_email( | ||||||||||||
| contract_email, | ||||||||||||
| settings.server, | ||||||||||||
| settings.username, | ||||||||||||
| settings.password, | ||||||||||||
| settings.insecure, | ||||||||||||
| ) | ||||||||||||
| contract_pdf_filename = ( | ||||||||||||
| f"{settings.company_name} {contract_yaml_filename.stem}.pdf" | ||||||||||||
| ) | ||||||||||||
| contract_mail_text = mail_template.render() | ||||||||||||
|
|
||||||||||||
| attachments = [(contract_pdf_path, contract_pdf_filename)] | ||||||||||||
|
|
||||||||||||
| for item in contract_data["items"]: | ||||||||||||
| item_pdf_file = f"{item['description']}.pdf" | ||||||||||||
| item_pdf_path = Path(settings.assets_dir / item_pdf_file) | ||||||||||||
| if item_pdf_path.is_file(): | ||||||||||||
| attachments.append((item_pdf_path, item_pdf_file)) | ||||||||||||
| else: | ||||||||||||
| print(f"Item file {item_pdf_file} not found") | ||||||||||||
|
|
||||||||||||
| if settings.policy_attachment_asset_file: | ||||||||||||
| policy_pdf_path = settings.policy_attachment_asset_file | ||||||||||||
| if policy_pdf_path.is_file(): | ||||||||||||
| attachments.append((policy_pdf_path, policy_pdf_path.name)) | ||||||||||||
| else: | ||||||||||||
| print(f"Missing {settings.policy_attachment_asset_file.name}") | ||||||||||||
|
|
||||||||||||
| contract_email = generate_email( | ||||||||||||
| settings, | ||||||||||||
| contract_data["email"], | ||||||||||||
| settings.contract_mail_subject, | ||||||||||||
| contract_mail_text, | ||||||||||||
| attachments, | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| print("Sending contract {}".format(contract_data["cid"])) | ||||||||||||
|
|
||||||||||||
| send_email( | ||||||||||||
| contract_email, | ||||||||||||
| settings.server, | ||||||||||||
| settings.username, | ||||||||||||
| settings.password, | ||||||||||||
| settings.insecure, | ||||||||||||
| ) | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking the current
.gitignorewith the./lead-in usinggit check-ignore --verbose, it seems indeed like these rules are broken and do never match.However, it does not really seem like a good idea to me to add things like
contracts/orinvoices/to.gitignorewithout making them relative to the repository root:Imagine you are changing the
contract.pymodule inrechnunginto its owncontractspackage.With your change, this whole package would be ignored by git, because any directory that goes by the name of
contractswill be ignored anywhere in the repository.The better solution might be to change all occurrences of
./in the.gitignorewith/: