mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-02-17 07:03:58 +00:00
Merge conflicts
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
|
||||
2.0.0
|
||||
-----
|
||||
### New features
|
||||
@@ -10,6 +11,11 @@
|
||||
- `-o`/`--output` option is now a path to an output directory, instead of an
|
||||
output file
|
||||
|
||||
1.1.0
|
||||
-----
|
||||
- Add `extract_xml()` and `human_timespamp_to_datetime` methods
|
||||
|
||||
|
||||
1.0.5
|
||||
-----
|
||||
- Prefix public suffix and GeoIP2 database filenames with `.`
|
||||
|
||||
8
build.sh
Executable file
8
build.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
. ~/venv/domainaware/bin/activate
|
||||
cd docs && make html && cp -r _build/html/* ../../parsedmarc-docs/
|
||||
cd ..
|
||||
rm -rf dist/ build/
|
||||
python setup.py bdist_wheel
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
. ~/venv/domainaware/bin/activate
|
||||
cd docs && make html && cp -r build/html/* ../../parsedmarc-docs/
|
||||
@@ -191,7 +191,7 @@ def _timestamp_to_human(timestamp):
|
||||
return _timestamp_to_datetime(timestamp).strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
||||
def _human_timestamp_to_datetime(human_timestamp):
|
||||
def human_timestamp_to_datetime(human_timestamp):
|
||||
"""
|
||||
Converts a human-readable timestamp into a Python ``DateTime`` object
|
||||
|
||||
@@ -479,17 +479,17 @@ def parse_aggregate_report_xml(xml, nameservers=None, timeout=6.0):
|
||||
"{0}".format(error.__str__()))
|
||||
|
||||
|
||||
def parse_aggregate_report_file(input_, nameservers=None, timeout=6.0):
|
||||
"""Parses a file at the given path, a file-like object. or bytes as a
|
||||
aggregate DMARC report
|
||||
def extract_xml(input_):
|
||||
"""
|
||||
Extracts xml from a zip or gzip file at the given path, file-like object,
|
||||
or bytes.
|
||||
|
||||
Args:
|
||||
input_: A path to a file, a file like object, or bytes
|
||||
nameservers (list): A list of one or more nameservers to use
|
||||
timeout (float): Sets the DNS timeout in seconds
|
||||
|
||||
Returns:
|
||||
OrderedDict: The parsed DMARC aggregate report
|
||||
str: The extracted XML
|
||||
|
||||
"""
|
||||
if type(input_) == str or type(input_) == unicode:
|
||||
file_object = open(input_, "rb")
|
||||
@@ -512,10 +512,28 @@ def parse_aggregate_report_file(input_, nameservers=None, timeout=6.0):
|
||||
raise InvalidAggregateReport("Not a valid zip, gzip, or xml file")
|
||||
|
||||
file_object.close()
|
||||
|
||||
except UnicodeDecodeError:
|
||||
raise InvalidAggregateReport("File objects must be opened in binary "
|
||||
"(rb) mode")
|
||||
|
||||
return xml
|
||||
|
||||
|
||||
def parse_aggregate_report_file(_input, nameservers=None, timeout=6.0):
|
||||
"""Parses a file at the given path, a file-like object. or bytes as a
|
||||
aggregate DMARC report
|
||||
|
||||
Args:
|
||||
_input: A path to a file, a file like object, or bytes
|
||||
nameservers (list): A list of one or more nameservers to use
|
||||
timeout (float): Sets the DNS timeout in seconds
|
||||
|
||||
Returns:
|
||||
OrderedDict: The parsed DMARC aggregate report
|
||||
"""
|
||||
xml = extract_xml(_input)
|
||||
|
||||
return parse_aggregate_report_xml(xml,
|
||||
nameservers=nameservers,
|
||||
timeout=timeout)
|
||||
|
||||
Reference in New Issue
Block a user