Skip to content
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

language cleanups #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions failures-to-investigate/freshsales.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
#
# License _!_

from os.path import abspath, dirname, join as pjoin
import pprint
import sys
import time
from os.path import abspath, dirname
from os.path import join as pjoin

import requests

from icecream import ic

_corePath = abspath(pjoin(dirname(__file__), '../'))
if _corePath not in sys.path:
sys.path.append(_corePath)
from common.utils import lget


DEFAULT_FIRST_NAME = 'there'
DEFAULT_LAST_NAME = '-'
FRESH_SALES_API_KEY = 'P3bYheaquAHH1_hNxhMUDQ'
Expand Down Expand Up @@ -215,7 +216,7 @@ def createAndOrAssociateCompanyWithContact(websiteUrl, contact):
'id': companyToAdd['id'],
# There can only be one primary Company associated with a
# Contact. See https://www.freshsales.io/api/#create_contact.
'is_primary': False if companies else True,
'is_primary': not companies,
}
companies.append(companyData)

Expand All @@ -242,7 +243,7 @@ def upgradeContactWhoSubmittedSplashPage(contact, websiteUrl):

def noteContactSubmittedPepSplashPage(contact, websiteUrl):
createAndOrAssociateCompanyWithContact(websiteUrl, contact)

PEP = 9000004543
updateContact(contact['id'], {
'custom_field': {
Expand Down
9 changes: 5 additions & 4 deletions failures-to-investigate/freshsales2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
#
# License _!_

from os.path import abspath, dirname, join as pjoin
import pprint
import sys
import time
from os.path import abspath, dirname
from os.path import join as pjoin
from urllib.parse import urlparse

import requests

from icecream import ic

_corePath = abspath(pjoin(dirname(__file__), '../'))
if _corePath not in sys.path:
sys.path.append(_corePath)
from common.utils import lget, stripStringStart


DEFAULT_FIRST_NAME = 'there'
DEFAULT_LAST_NAME = '-'
FRESH_SALES_API_KEY = 'P3bYheaquAHH1_hNxhMUDQ'
Expand Down Expand Up @@ -228,7 +229,7 @@ def createAndOrAssociateCompanyWithContact(websiteUrl, contact):
'id': companyToAdd['id'],
# There can only be one primary Company associated with a
# Contact. See https://www.freshsales.io/api/#create_contact.
'is_primary': False if companies else True,
'is_primary': not companies,
}
companies.append(companyData)

Expand All @@ -255,7 +256,7 @@ def upgradeContactWhoSubmittedSplashPage(contact, websiteUrl):

def noteContactSubmittedPepSplashPage(contact, websiteUrl):
createAndOrAssociateCompanyWithContact(websiteUrl, contact)

PEP = 9000004543
updateContact(contact['id'], {
'custom_field': {
Expand Down
9 changes: 5 additions & 4 deletions failures-to-investigate/freshsales3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
#
# License _!_

from os.path import abspath, dirname, join as pjoin
import pprint
import sys
import time
from os.path import abspath, dirname
from os.path import join as pjoin
from urllib.parse import urlparse

import requests

from icecream import ic

_corePath = abspath(pjoin(dirname(__file__), '../'))
if _corePath not in sys.path:
sys.path.append(_corePath)
from common.utils import lget, stripStringStart


DEFAULT_FIRST_NAME = 'there'
DEFAULT_LAST_NAME = '-'
FRESH_SALES_API_KEY = 'P3bYheaquAHH1_hNxhMUDQ'
Expand Down Expand Up @@ -235,7 +236,7 @@ def createAndOrAssociateCompanyWithContact(websiteUrl, contact):
'id': companyToAdd['id'],
# There can only be one primary Company associated with a
# Contact. See https://www.freshsales.io/api/#create_contact.
'is_primary': False if companies else True,
'is_primary': not companies,
}
companies.append(companyData)

Expand All @@ -262,7 +263,7 @@ def upgradeContactWhoSubmittedSplashPage(contact, websiteUrl):

def noteContactSubmittedPepSplashPage(contact, websiteUrl):
createAndOrAssociateCompanyWithContact(websiteUrl, contact)

PEP = 9000004543
updateContact(contact['id'], {
'custom_field': {
Expand Down
9 changes: 5 additions & 4 deletions icecream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
# License: MIT
#

from os.path import dirname, join as pjoin

from .icecream import * # noqa
from .builtins import install, uninstall
from os.path import dirname
from os.path import join as pjoin

# Import all variables in __version__.py without explicit imports.
from . import __version__
from .builtins import install, uninstall
from .icecream import * # noqa

globals().update(dict((k, v) for k, v in __version__.__dict__.items()))
1 change: 0 additions & 1 deletion icecream/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import icecream


try:
builtins = __import__('__builtin__')
except ImportError:
Expand Down
6 changes: 3 additions & 3 deletions icecream/coloring.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#

from pygments.style import Style
from pygments.token import (
Text, Name, Error, Other, String, Number, Keyword, Generic, Literal,
Comment, Operator, Whitespace, Punctuation)
from pygments.token import (Comment, Error, Generic, Keyword, Literal, Name,
Number, Operator, Other, Punctuation, String, Text,
Whitespace)


# Solarized: https://ethanschoonover.com/solarized/
Expand Down
14 changes: 7 additions & 7 deletions icecream/icecream.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
from __future__ import print_function

import ast
import functools
import inspect
import pprint
import sys
import warnings
from datetime import datetime
import functools
from contextlib import contextmanager
from datetime import datetime
from os.path import basename, realpath
from textwrap import dedent

Expand All @@ -31,12 +31,12 @@
# terminals and thus whether to use Terminal256Formatter or
# TerminalTrueColorFormatter.
from pygments.formatters import Terminal256Formatter
from pygments.lexers import PythonLexer as PyLexer, Python3Lexer as Py3Lexer
from pygments.lexers import Python3Lexer as Py3Lexer
from pygments.lexers import PythonLexer as PyLexer

from .coloring import SolarizedDark


PYTHON2 = (sys.version_info[0] == 2)
PYTHON2 = sys.version_info[0] == 2

_absent = object()
_arg_source_missing = object()
Expand Down Expand Up @@ -172,7 +172,7 @@ def unsupport_py2(*args, **kwargs):
func = functools.singledispatch(func)

# add unregister based on https://stackoverflow.com/a/25951784
closure = dict(zip(func.register.__code__.co_freevars,
closure = dict(zip(func.register.__code__.co_freevars,
func.register.__closure__))
registry = closure['registry'].cell_contents
dispatch_cache = closure['dispatch_cache'].cell_contents
Expand Down Expand Up @@ -366,7 +366,7 @@ def configureOutput(self, prefix=_absent, outputFunction=_absent,

if includeContext is not _absent:
self.includeContext = includeContext

if contextAbsPath is not _absent:
self.contextAbsPath = contextAbsPath

Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@

import os
import sys
from os.path import dirname, join as pjoin
from setuptools import setup, find_packages, Command
from setuptools.command.test import test as TestCommand
from os.path import dirname
from os.path import join as pjoin

from setuptools import Command, find_packages, setup
from setuptools.command.test import test as TestCommand

meta = {}
with open(pjoin('icecream', '__version__.py')) as f:
Expand Down
10 changes: 6 additions & 4 deletions tests/test_icecream.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
from StringIO import StringIO
except ImportError: # Python 3.x.
from io import StringIO

from contextlib import contextmanager
from os.path import basename, splitext, realpath
from os.path import basename, realpath, splitext

import icecream
from icecream import ic, argumentToString, stderrPrint, NO_SOURCE_AVAILABLE_WARNING_MESSAGE
from icecream import (NO_SOURCE_AVAILABLE_WARNING_MESSAGE, argumentToString,
ic, stderrPrint)

TEST_PAIR_DELIMITER = '| '
MY_FILENAME = basename(__file__)
Expand Down Expand Up @@ -505,7 +507,7 @@ def testContextAbsPathMultiLine(self):

pair = parseOutputIntoPairs(out, err, 3)[1][0]
assert pair == ('multilineStr', ic.argToStringFunction(multilineStr))

def testFormat(self):
with disableColoring(), captureStandardStreams() as (out, err):
"""comment"""; noop(); ic( # noqa
Expand Down Expand Up @@ -595,7 +597,7 @@ def testMultilineContainerArgs(self):
list(range(15))])

lines = err.getvalue().strip().splitlines()
self.assertRegexpMatches(
self.assertRegex(
lines[0],
r'ic\| test_icecream.py:\d+ in testMultilineContainerArgs\(\)',
)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

import unittest

import icecream
from test_icecream import (
disableColoring, captureStandardStreams, parseOutputIntoPairs)

from install_test_import import runMe
from test_icecream import (captureStandardStreams, disableColoring,
parseOutputIntoPairs)

import icecream


class TestIceCreamInstall(unittest.TestCase):
Expand Down