Skip to content

Commit

Permalink
Upgrade to new cPyparsing
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed Jul 25, 2023
1 parent d70886b commit 46610fb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
8 changes: 6 additions & 2 deletions coconut/command/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ def execute_args(self, args, interact=True, original_args=None):
args.trace = args.profile = False

# set up logger
logger.quiet, logger.verbose, logger.tracing = args.quiet, args.verbose, args.trace
logger.setup(
quiet=args.quiet,
verbose=args.verbose,
tracing=args.trace,
)
if args.verbose or args.trace or args.profile:
set_grammar_names()
if args.trace or args.profile:
Expand Down Expand Up @@ -571,7 +575,7 @@ def compile(self, codepath, destpath=None, package=False, run=False, force=False
foundhash = None if force else self.has_hash_of(destpath, code, package_level)
if foundhash:
if show_unchanged:
logger.show_tabulated("Left unchanged", showpath(destpath), "(pass --force to override).")
logger.show_tabulated("Left unchanged", showpath(destpath), "(pass --force to overwrite).")
if self.show:
logger.print(foundhash)
if run:
Expand Down
11 changes: 5 additions & 6 deletions coconut/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,18 +601,17 @@ def get_bool_env_var(env_var, default=False):
style_env_var = "COCONUT_STYLE"
vi_mode_env_var = "COCONUT_VI_MODE"
home_env_var = "COCONUT_HOME"
use_color_env_var = "COCONUT_USE_COLOR"

coconut_home = fixpath(os.getenv(home_env_var, "~"))

use_color = get_bool_env_var(use_color_env_var, default=None)
use_color = get_bool_env_var("COCONUT_USE_COLOR", None)
error_color_code = "31"
log_color_code = "93"

default_style = "default"
prompt_histfile = os.path.join(coconut_home, ".coconut_history")
prompt_multiline = False
prompt_vi_mode = get_bool_env_var(vi_mode_env_var)
prompt_vi_mode = get_bool_env_var(vi_mode_env_var, False)
prompt_wrap_lines = True
prompt_history_search = True
prompt_use_suggester = False
Expand Down Expand Up @@ -688,7 +687,7 @@ def get_bool_env_var(env_var, default=False):

interpreter_uses_auto_compilation = True
interpreter_uses_coconut_breakpoint = True
interpreter_uses_incremental = False
interpreter_uses_incremental = get_bool_env_var("COCONUT_INTERPRETER_INCREMENTAL_PARSING", False)

command_resources_dir = os.path.join(base_dir, "command", "resources")
coconut_pth_file = os.path.join(command_resources_dir, "zcoconut.pth")
Expand Down Expand Up @@ -848,7 +847,7 @@ def get_bool_env_var(env_var, default=False):
license_name = "Apache 2.0"

pure_python_env_var = "COCONUT_PURE_PYTHON"
PURE_PYTHON = get_bool_env_var(pure_python_env_var)
PURE_PYTHON = get_bool_env_var(pure_python_env_var, False)

# the different categories here are defined in requirements.py,
# tuples denote the use of environment markers
Expand Down Expand Up @@ -940,7 +939,7 @@ def get_bool_env_var(env_var, default=False):

# min versions are inclusive
min_versions = {
"cPyparsing": (2, 4, 7, 2, 1, 2),
"cPyparsing": (2, 4, 7, 2, 2, 0),
("pre-commit", "py3"): (3,),
("psutil", "py>=27"): (5,),
"jupyter": (1, 0),
Expand Down
2 changes: 1 addition & 1 deletion coconut/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
VERSION = "3.0.2"
VERSION_NAME = None
# False for release, int >= 1 for develop
DEVELOP = 29
DEVELOP = 30
ALPHA = False # for pre releases rather than post releases

assert DEVELOP is False or DEVELOP >= 1, "DEVELOP must be False or an int >= 1"
Expand Down
13 changes: 12 additions & 1 deletion coconut/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
error_color_code,
log_color_code,
ansii_escape,
get_bool_env_var,
)
from coconut.util import (
get_clock_time,
Expand Down Expand Up @@ -178,7 +179,8 @@ def logging(self):

class Logger(object):
"""Container object for various logger functions and variables."""
verbose = False
force_verbose = get_bool_env_var("COCONUT_FORCE_VERBOSE", False)
verbose = force_verbose
quiet = False
path = None
name = None
Expand Down Expand Up @@ -215,6 +217,15 @@ def copy(self):
"""Make a copy of the logger."""
return Logger(self)

def setup(self, quiet=None, verbose=None, tracing=None):
"""Set up the logger with the given parameters."""
if quiet is not None:
self.quiet = quiet
if not self.force_verbose and verbose is not None:
self.verbose = verbose
if tracing is not None:
self.tracing = tracing

def display(
self,
messages,
Expand Down

0 comments on commit 46610fb

Please sign in to comment.