Exemple #1
0
    def test_warn_if_outdated(self):
        with catch_warnings(record=True) as w:
            warn_if_outdated(self.package,
                             self.version,
                             raise_exceptions=True,
                             background=False)
            self.assertEqual(len(w), 0)

        with self.assert_warns(OutdatedPackageWarning,
                               ('The package ask-so is out of date. '
                                'Your version is 0.1, the latest is 1.0.4.')):
            warn_if_outdated(self.package,
                             '0.1',
                             raise_exceptions=True,
                             background=False)

        with disable_cache():
            with fail_get_url():
                with self.assert_warns(
                        OutdatedCheckFailedWarning,
                    ('Failed to check for latest version of package.\n'
                     'Set the environment variable OUTDATED_RAISE_EXCEPTION=1 for a full traceback.'
                     )):
                    warn_if_outdated(self.package, '0.1', background=False)

                with self.assertRaises(ValueError):
                    warn_if_outdated(self.package,
                                     '0.1',
                                     raise_exceptions=True,
                                     background=False)

        warn_if_outdated(self.package, self.version)
Exemple #2
0
# Import pingouin objects
from .utils import *
from .bayesian import *
from .datasets import *
from .distribution import *
from .effsize import *
from .equivalence import *
from .multicomp import *
from .multivariate import *
from .parametric import *
from .nonparametric import *
from .correlation import *
from .circular import *
from .pairwise import *
from .power import *
from .reliability import *
from .regression import *
from .plotting import *
from .contingency import *
from .config import *

# Current version
__version__ = "0.3.9"

# Warn if a newer version of Pingouin is available
from outdated import warn_if_outdated
warn_if_outdated("pingouin", __version__)

# load default options
set_default_options()
Exemple #3
0
    class DataFrame(object):
        pass

    class Series(object):
        pass


try:
    from django.db.models import QuerySet
except ImportError:

    class QuerySet(object):
        pass


warn_if_outdated('birdseye', __version__)

CodeInfo = namedtuple('CodeInfo', 'db_func traced_file arg_names')


class BirdsEye(TreeTracerBase):
    """
    Decorate functions with an instance of this class to debug them,
    or just use the existing instance `eye`.
    """
    def __init__(self, db_uri=None, num_samples=None):
        """
        Set db_uri to specify where the database lives, as an alternative to
        the environment variable BIRDSEYE_DB.
        """
        super(BirdsEye, self).__init__()
Exemple #4
0
def main():
    warn_if_outdated('mint-amazon-tagger', VERSION)
    is_outdated, latest_version = check_outdated('mint-amazon-tagger', VERSION)
    if is_outdated:
        print('Please update your version by running:\n'
              'pip3 install mint-amazon-tagger --upgrade')

    parser = argparse.ArgumentParser(
        description='Tag Mint transactions based on itemized Amazon history.')
    define_args(parser)
    args = parser.parse_args()

    if args.version:
        print('mint-amazon-tagger {}\nBy: Jeff Prouty'.format(VERSION))
        exit(0)

    session_path = args.session_path
    if session_path.lower() == 'none':
        session_path = None

    items_csv = args.items_csv
    orders_csv = args.orders_csv
    refunds_csv = args.refunds_csv

    start_date = None
    if not items_csv or not orders_csv:
        logger.info('Missing Items/Orders History csv. Attempting to fetch '
                    'from Amazon.com.')
        start_date = args.order_history_start_date
        duration = datetime.timedelta(days=args.order_history_num_days)
        end_date = datetime.date.today()
        # If a start date is given, adjust the end date based on num_days,
        # ensuring not to go beyond today.
        if start_date:
            start_date = start_date.date()
            if start_date + duration < end_date:
                end_date = start_date + duration
        else:
            start_date = end_date - duration
        items_csv, orders_csv, refunds_csv = fetch_order_history(
            args.report_download_location, start_date, end_date,
            args.amazon_email, args.amazon_password, session_path,
            args.headless)

    if not items_csv or not orders_csv:  # Refunds are optional
        logger.critical('Order history either not provided at command line or '
                        'unable to fetch. Exiting.')
        exit(1)

    orders = amazon.Order.parse_from_csv(orders_csv,
                                         ProgressCounter('Parsing Orders - '))
    items = amazon.Item.parse_from_csv(items_csv,
                                       ProgressCounter('Parsing Items - '))
    refunds = ([] if not refunds_csv else amazon.Refund.parse_from_csv(
        refunds_csv, ProgressCounter('Parsing Refunds - ')))

    if args.dry_run:
        logger.info('\nDry Run; no modifications being sent to Mint.\n')

    # Initialize the stats. Explicitly initialize stats that might not be
    # accumulated (conditionals).
    stats = Counter(
        adjust_itemized_tax=0,
        already_up_to_date=0,
        misc_charge=0,
        new_tag=0,
        no_retag=0,
        retag=0,
        user_skipped_retag=0,
        personal_cat=0,
    )

    mint_client = MintClient(args.mint_email, args.mint_password, session_path,
                             args.headless, args.mint_mfa_method,
                             args.wait_for_sync)

    if args.pickled_epoch:
        mint_trans, mint_category_name_to_id = (
            get_trans_and_categories_from_pickle(args.pickled_epoch,
                                                 args.mint_pickle_location))
    else:
        # Get the date of the oldest Amazon order.
        if not start_date:
            start_date = min([o.order_date for o in orders])
            if refunds:
                start_date = min(start_date,
                                 min([o.order_date for o in refunds]))

        # Double the length of transaction history to help aid in
        # personalized category tagging overrides.
        today = datetime.date.today()
        start_date = today - (today - start_date) * 2
        mint_category_name_to_id = mint_client.get_categories()
        mint_transactions_json = mint_client.get_transactions(start_date)

        epoch = int(time.time())
        mint_trans = mint.Transaction.parse_from_json(mint_transactions_json)
        dump_trans_and_categories(mint_trans, mint_category_name_to_id, epoch,
                                  args.mint_pickle_location)

    updates, unmatched_orders = tagger.get_mint_updates(
        orders, items, refunds, mint_trans, args, stats,
        mint_category_name_to_id)

    log_amazon_stats(items, orders, refunds)
    log_processing_stats(stats)

    if args.print_unmatched and unmatched_orders:
        logger.warning(
            'The following were not matched to Mint transactions:\n')
        by_oid = defaultdict(list)
        for uo in unmatched_orders:
            by_oid[uo.order_id].append(uo)
        for unmatched_by_oid in by_oid.values():
            orders = [o for o in unmatched_by_oid if o.is_debit]
            refunds = [o for o in unmatched_by_oid if not o.is_debit]
            if orders:
                print_unmatched(amazon.Order.merge(orders))
            for r in amazon.Refund.merge(refunds):
                print_unmatched(r)

    if not updates:
        logger.info(
            'All done; no new tags to be updated at this point in time!')
        exit(0)

    if args.dry_run:
        logger.info('Dry run. Following are proposed changes:')
        if args.skip_dry_print:
            logger.info('Dry run print results skipped!')
        else:
            tagger.print_dry_run(updates,
                                 ignore_category=args.no_tag_categories)

    else:
        mint_client.send_updates(updates,
                                 ignore_category=args.no_tag_categories)
Exemple #5
0
################################################################################
# Module: __init__.py
# Description: trnslator: Convert IDF file (EnergyPlus) to BUI file (TRNBuild)
# License: -
# Web: https://github.com/louisleroy5/trnslator
################################################################################

# Version of the package
__version__ = "1.1.1"

# warn if a newer version of trnslator is available
from outdated import warn_if_outdated
from .utils import warn_if_not_compatible

warn_if_outdated("trnslator", __version__)
warn_if_not_compatible()

from .utils import *
from .energyseries import EnergySeries
from .energydataframe import EnergyDataFrame
from .reportdata import ReportData
from .idfclass import *
from .schedule import Schedule
from .trnsys import *
from .cli import *
Exemple #6
0
################################################################################
# Module: __init__.py
# Description: Archetypal: Retrieve, construct and analyse building archetypes
# License: MIT, see full license in LICENSE.txt
# Web: https://github.com/samuelduchesne/archetypal
################################################################################

# Version of the package
__version__ = "1.3.4"

# warn if a newer version of archetypal is available
from outdated import warn_if_outdated
from .utils import warn_if_not_compatible

warn_if_outdated("archetypal", __version__)
warn_if_not_compatible()

from .utils import *
from .simple_glazing import *
from .energyseries import EnergySeries
from .energydataframe import EnergyDataFrame
from .reportdata import ReportData
from .tabulardata import TabularData
from .idfclass import *
from .schedule import Schedule
from .dataportal import *
from .plot import *
from .trnsys import *
from .template import *
from .umi_template import *
from .cli import *
Exemple #7
0
import logging
from .detection import *
from .features import *
from .hypno import *
from .numba import *
from .others import *
from .plotting import *
from .sleepstats import *
from .spectral import *
from .staging import *
from outdated import warn_if_outdated

# Define YASA logger
logging.basicConfig(format='%(asctime)s | %(levelname)s | %(message)s',
                    datefmt='%d-%b-%y %H:%M:%S')

__author__ = "Raphael Vallat <*****@*****.**>"
__version__ = "0.4.1"

# Warn if a newer version of YASA is available
warn_if_outdated("yasa", __version__)
Exemple #8
0
    class Series(object):
        pass


try:
    from django.db.models import QuerySet
except Exception:

    class QuerySet(object):
        pass


try:
    from outdated import warn_if_outdated

    warn_if_outdated("birdseye", __version__)
except Exception:
    pass

# noinspection PyUnreachableCode
if False:
    from typing import (
        List,
        Dict,
        Any,
        Optional,
        Tuple,
        Iterator,
        Iterable,
        Union,
    )