Skip to content

Commit

Permalink
Rename modules to remove eg_* prefix.
Browse files Browse the repository at this point in the history
The leading eg_* prefix was decided to be bad style and
redundant. eg_util is obviously the eg util, as you import it
from eg. Since we're breaking eg_exec.py with the next
version in order to support python 3.x, decided it makes
sense to throw in this other large change to further motivate
incrementing the minor version number.
  • Loading branch information
srsudar committed Apr 27, 2015
1 parent dd5fbf3 commit 0a625d3
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 140 deletions.
4 changes: 2 additions & 2 deletions eg/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from eg import eg_core
from eg import core


eg_core.run_eg()
core.run_eg()
File renamed without changes.
File renamed without changes.
22 changes: 12 additions & 10 deletions eg/eg_core.py → eg/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import pydoc
import sys

from eg import eg_config
from eg import eg_util
from eg import config
from eg import util


def run_eg():
Expand Down Expand Up @@ -71,9 +71,11 @@ def run_eg():
if len(sys.argv) < 2:
parser.print_help()
elif not args.version and not args.list and not args.program:
print('you must specify a program or pass the --list or --version flags')
print(
'you must specify a program or pass the --list or --version flags'
)
else:
config = eg_config.get_resolved_config_items(
resolved_config = config.get_resolved_config_items(
egrc_path=args.config_file,
examples_dir=args.examples_dir,
custom_dir=args.custom_dir,
Expand All @@ -83,16 +85,16 @@ def run_eg():

if args.list:
# Show what's available.
supported_programs = eg_util.get_list_of_all_supported_commands(
config
supported_programs = util.get_list_of_all_supported_commands(
resolved_config
)
msg_line_1 = 'Legend: '
msg_line_2 = (' ' +
eg_util.FLAG_ONLY_CUSTOM +
util.FLAG_ONLY_CUSTOM +
' only custom files'
)
msg_line_3 = (' ' +
eg_util.FLAG_CUSTOM_AND_DEFAULT +
util.FLAG_CUSTOM_AND_DEFAULT +
' custom and default files'
)
msg_line_4 = ' ' + ' only default files (no symbol)'
Expand All @@ -113,9 +115,9 @@ def run_eg():

pydoc.pager(complete_message)
elif args.version:
print(eg_util.VERSION)
print(util.VERSION)
else:
eg_util.handle_program(args.program, config)
util.handle_program(args.program, resolved_config)


# We want people to be able to use eg without pip, by so we'll allow this to be
Expand Down
4 changes: 2 additions & 2 deletions eg/eg_util.py → eg/util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import pydoc

from eg import eg_colorizer
from eg import color


# The file name suffix expected for example files.
Expand Down Expand Up @@ -114,7 +114,7 @@ def open_pager_for_file(
file_data += _get_contents_of_file(default_file_path)

if use_color:
colorizer = eg_colorizer.EgColorizer(color_config)
colorizer = color.EgColorizer(color_config)
file_data = colorizer.colorize_text(file_data)

page_string(file_data, pager_cmd)
Expand Down
4 changes: 2 additions & 2 deletions eg_exec.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python
from eg import eg_core
from eg import core


eg_core.run_eg()
core.run_eg()
24 changes: 12 additions & 12 deletions test/eg_colorizer_test.py → test/color_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

from collections import namedtuple
from eg import eg_colorizer
from eg import eg_config
from eg import color
from eg import config
from mock import patch
from nose.tools import assert_equal

Expand Down Expand Up @@ -111,7 +111,7 @@ def get_data_with_subs(

def test_colorize_heading():
"""Makes sure we colorize things like '# find' correctly"""
color_config = eg_config.ColorConfig(
color_config = config.ColorConfig(
'P',
'H',
_YELLOW,
Expand All @@ -135,7 +135,7 @@ def test_colorize_heading():
heading_reset=color_config.heading_reset
)

colorizer = eg_colorizer.EgColorizer(color_config)
colorizer = color.EgColorizer(color_config)

actual = colorizer.colorize_heading(clean)

Expand All @@ -144,7 +144,7 @@ def test_colorize_heading():

def test_colorize_block_indents():
"""Makes sure we colorize block indents correctly."""
color_config = eg_config.ColorConfig(
color_config = config.ColorConfig(
_BLACK,
_MAGENTA,
'C',
Expand All @@ -168,7 +168,7 @@ def test_colorize_block_indents():
prompt_reset=color_config.prompt_reset
)

colorizer = eg_colorizer.EgColorizer(color_config)
colorizer = color.EgColorizer(color_config)

actual = colorizer.colorize_block_indent(clean)

Expand All @@ -177,7 +177,7 @@ def test_colorize_block_indents():

def test_colorize_backticks():
"""Makes sure we colorize backticks correctly."""
color_config = eg_config.ColorConfig(
color_config = config.ColorConfig(
_BLACK,
_MAGENTA,
_YELLOW,
Expand All @@ -199,7 +199,7 @@ def test_colorize_backticks():
backticks_reset=color_config.backticks_reset,
)

colorizer = eg_colorizer.EgColorizer(color_config)
colorizer = color.EgColorizer(color_config)

actual = colorizer.colorize_backticks(clean)

Expand All @@ -209,18 +209,18 @@ def test_colorize_backticks():
def test_colorize_text_calls_all_sub_methods():
"""colorize_text should call all of the helper colorize methods."""
with patch(
'eg.eg_colorizer.EgColorizer.colorize_heading',
'eg.color.EgColorizer.colorize_heading',
return_value='text-heading'
) as heading:
with patch(
'eg.eg_colorizer.EgColorizer.colorize_block_indent',
'eg.color.EgColorizer.colorize_block_indent',
return_value='text-heading-indent'
) as indent:
with patch(
'eg.eg_colorizer.EgColorizer.colorize_backticks',
'eg.color.EgColorizer.colorize_backticks',
return_value='text-heading-indent-backticks'
) as backticks:
colorizer = eg_colorizer.EgColorizer(None)
colorizer = color.EgColorizer(None)
text = 'text'
actual = colorizer.colorize_text(text)
heading.assert_called_once_with(text)
Expand Down
Loading

0 comments on commit 0a625d3

Please sign in to comment.