Changeset - fd548f35f4b9
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-06-23 20:46:31
brettcsmith@brettcsmith.org
accrual: Be case-insensitive when gathering payment-method.

This is a little nicer for the user, and lets us simplify surrounding
case-handling code.
2 files changed with 18 insertions and 15 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/accrual.py
Show inline comments
...
 
@@ -484,6 +484,3 @@ class OutgoingReport(BaseReport):
 
    }
 
    PAYMENT_METHOD_RE = re.compile(
 
        rf'^([A-Z]{{3}})\s+({"|".join(PAYMENT_METHODS)})$',
 
        re.IGNORECASE,
 
    )
 
    PAYMENT_METHOD_RE = re.compile(rf'^([a-z]{{3}})\s+({"|".join(PAYMENT_METHODS)})$')
 

	
...
 
@@ -581,6 +578,16 @@ class OutgoingReport(BaseReport):
 
        }
 
        payment_methods = posts.meta_values('payment-method')
 
        payment_methods.discard(None)
 
        payment_method_count = len(payment_methods)
 
        if payment_method_count != 1:
 
        payment_methods = filters.iter_unique(
 
            post.meta['payment-method'].lower()
 
            for post in posts
 
            if isinstance(post.meta.get('payment-method'), str)
 
        )
 
        payment_method: Optional[str] = next(payment_methods, None)
 
        if payment_method is None:
 
            payment_method_count = "no"
 
        elif next(payment_methods, None) is None:
 
            pass
 
        else:
 
            payment_method_count = "multiple"
 
            payment_method = None
 
        if payment_method is None:
 
            self.logger.warning(
...
 
@@ -590,7 +597,3 @@ class OutgoingReport(BaseReport):
 
        else:
 
            payment_method = payment_methods.pop()
 
            if isinstance(payment_method, str):
 
                match = self.PAYMENT_METHOD_RE.fullmatch(payment_method)
 
            else:
 
                match = None
 
            match = self.PAYMENT_METHOD_RE.fullmatch(payment_method)
 
            if match is None:
...
 
@@ -603,3 +606,3 @@ class OutgoingReport(BaseReport):
 
                    match.group(1).upper(),
 
                    self.PAYMENT_METHODS[match.group(2).lower()],
 
                    self.PAYMENT_METHODS[match.group(2)],
 
                )
setup.py
Show inline comments
...
 
@@ -7,3 +7,3 @@ setup(
 
    description="Plugin, library, and reports for reading Conservancy's books",
 
    version='1.4.0',
 
    version='1.4.1',
 
    author='Software Freedom Conservancy',
0 comments (0 inline, 0 general)