Skip to content

Commit

Permalink
Adds logger and activate level=DEBUG on cli flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdottom committed Jun 27, 2018
1 parent f157c9a commit 5681a15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
7 changes: 6 additions & 1 deletion thanks/cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# -*- coding: utf-8 -*-

"""Console script for thanks."""
import logging

import click
from thanks.thanks import Thanks

logging.basicConfig(level=logging.CRITICAL)
logger = logging.getLogger("thanks")


@click.command()
@click.argument("package_name",
Expand All @@ -27,9 +31,10 @@
def main(package_name, requirements,
# pipfile, setuppy,
debug, outfile):
if debug:
logger.level = logging.DEBUG
thanks = Thanks(debug=debug)
for p in package_name:
print(p)
thanks.package(p)
for r in requirements:
requirements_list = r.read().splitlines()
Expand Down
11 changes: 4 additions & 7 deletions thanks/thanks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from collections import namedtuple
from humanfriendly.tables import format_pretty_table
import json
import logging
import os
import requirements
import requests
Expand All @@ -13,6 +14,8 @@
from . import package_tools


logger = logging.getLogger("thanks")

JSON_FILE = ("{}/thanks.json".format(os.path.dirname(os.path.realpath(__file__))))

ProjectData = namedtuple('ProjectData', ['name', 'funding_link', 'authors'])
Expand All @@ -24,8 +27,7 @@ def __init__(self, debug=False):
self.give_thanks_to = {}

def package(self, package_name):
if self.debug:
print('Checking ', package_name)
logger.debug("Checking {}".format(package_name))
package_data = (self._get_local_data(package_name)
or self._get_remote_data(package_name))
if package_data:
Expand All @@ -43,10 +45,6 @@ def requirements_list(self, requirements_list):
# def pipfile(self, pipfile):
# pass

def _display_thanks(self):
if self.give_thanks_to:
print(self._generate_output())

def _get_local_data(self, project_name):
try:
metadata = package_tools.get_local_metadata(project_name)
Expand Down Expand Up @@ -82,7 +80,6 @@ def _get_remote_data(self, project_name):
data = None
return data


def _generate_output(self, colored_output=True):
def _uncolored(text, *args, **kwargs):
return text
Expand Down

0 comments on commit 5681a15

Please sign in to comment.