Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feature/output_fo…
Browse files Browse the repository at this point in the history
…rmatter
  • Loading branch information
meeuw committed Apr 15, 2017
2 parents 9c70ce1 + a380707 commit cdbc7cd
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 28 deletions.
14 changes: 14 additions & 0 deletions DEVELOP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,17 @@ after asking a few questions like maintainer name, email etc.

$ vagrant up

PEP8 checks
-----------

When you submit a PR, the changeset is checked for pep8 compliance using
`pep8radius <https://github.com/hayd/pep8radius>`_. If you see a build failing because
of these checks, install pep8radius and apply style fixes:

::

$ pip install pep8radius
$ pep8radius --docformatter --diff # view a diff of proposed fixes
$ pep8radius --docformatter --in-place # apply the fixes

Then commit and push the fixes.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ $ sudo apt-get install mycli # Only on debian or ubuntu

Options:
-h, --host TEXT Host address of the database.
-P, --port TEXT Port number to use for connection. Honors
-P, --port INTEGER Port number to use for connection. Honors
$MYSQL_TCP_PORT
-u, --user TEXT User name to connect to the database.
-S, --socket TEXT The socket file to use for connection.
-p, --password Force password prompt.
-p, --password TEXT Password to connect to the database
--pass TEXT Password to connect to the database
--ssl-ca PATH CA file in PEM format
--ssl-capath TEXT CA directory
Expand All @@ -58,18 +58,21 @@ $ sudo apt-get install mycli # Only on debian or ubuntu
against hostname used when connecting. This
option is disabled by default
-v, --version Version of mycli.
-D, --database TEXT Database to use.
-D, --database TEXT Database to use.
-R, --prompt TEXT Prompt format (Default: "\t \u@\h:\d> ")
-l, --logfile FILENAME Log every query and its results to a file.
--defaults-group-suffix TEXT Read config group with the specified suffix.
--defaults-file PATH Only read default options from the given file
--myclirc PATH Location of myclirc file.
--auto-vertical-output Automatically switch to vertical output mode
if the result is wider than the terminal
width.
-t, --table Display batch output in table format.
--csv Display batch output in CSV format.
--warn / --no-warn Warn before running a destructive query.
--local-infile BOOLEAN Enable/disable LOAD DATA LOCAL INFILE.
--login-path TEXT Read this path from the login file.
-e, --execute TEXT Execute query to the database.
--help Show this message and exit.

### Examples
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Features:
* Add ability to specify alternative myclirc file. (Thanks: [Dick Marinus]).
* Add new display formats for pretty printing query results. (Thanks: [Amjith
Ramanujam], [Dick Marinus], [Thomas Roten]).
* Add logic to shorten the default prompt if it becomes too long once generated. (Thanks: [John Sterling]).

Bug Fixes:
----------
Expand All @@ -26,6 +27,7 @@ Internal Changes:
Roten]).
* Test mycli using pexpect/python-behave (Thanks: [Dick Marinus]).
* Run pep8 checks in travis (Thanks: [Irina Truong]).
* Remove temporary hack for sqlparse (Thanks: [Dick Marinus]).

1.9.0:
======
Expand Down
6 changes: 5 additions & 1 deletion mycli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def emit(self, record):
class MyCli(object):

default_prompt = '\\t \\u@\\h:\\d> '
max_len_prompt = 45
defaults_suffix = None

# In order of being loaded. Files lower in list override earlier ones.
Expand Down Expand Up @@ -452,7 +453,10 @@ def run_cli(self):
print('Thanks to the contributor -', thanks_picker([author_file, sponsor_file]))

def prompt_tokens(cli):
return [(Token.Prompt, self.get_prompt(self.prompt_format))]
prompt = self.get_prompt(self.prompt_format)
if self.prompt_format == self.default_prompt and len(prompt) > self.max_len_prompt:
prompt = self.get_prompt('\\d> ')
return [(Token.Prompt, prompt)]

def get_continuation_tokens(cli, width):
continuation_prompt = self.get_prompt(self.prompt_continuation_format)
Expand Down
44 changes: 20 additions & 24 deletions mycli/packages/completion_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,28 @@ def suggest_type(full_text, text_before_cursor):

identifier = None

# This is a temporary hack; the exception handling
# here should be removed once sqlparse has been fixed
try:
# If we've partially typed a word then word_before_cursor won't be an empty
# string. In that case we want to remove the partially typed string before
# sending it to the sqlparser. Otherwise the last token will always be the
# partially typed string which renders the smart completion useless because
# it will always return the list of keywords as completion.
if word_before_cursor:
if word_before_cursor[-1] == '(' or word_before_cursor[0] == '\\':
parsed = sqlparse.parse(text_before_cursor)
else:
parsed = sqlparse.parse(
text_before_cursor[:-len(word_before_cursor)])
# If we've partially typed a word then word_before_cursor won't be an empty
# string. In that case we want to remove the partially typed string before
# sending it to the sqlparser. Otherwise the last token will always be the
# partially typed string which renders the smart completion useless because
# it will always return the list of keywords as completion.
if word_before_cursor:
if word_before_cursor.endswith(
'(') or word_before_cursor.startswith('\\'):
parsed = sqlparse.parse(text_before_cursor)
else:
parsed = sqlparse.parse(
text_before_cursor[:-len(word_before_cursor)])

# word_before_cursor may include a schema qualification, like
# "schema_name.partial_name" or "schema_name.", so parse it
# separately
p = sqlparse.parse(word_before_cursor)[0]
# word_before_cursor may include a schema qualification, like
# "schema_name.partial_name" or "schema_name.", so parse it
# separately
p = sqlparse.parse(word_before_cursor)[0]

if p.tokens and isinstance(p.tokens[0], Identifier):
identifier = p.tokens[0]
else:
parsed = sqlparse.parse(text_before_cursor)
except (TypeError, AttributeError):
return []
if p.tokens and isinstance(p.tokens[0], Identifier):
identifier = p.tokens[0]
else:
parsed = sqlparse.parse(text_before_cursor)

if len(parsed) > 1:
# Multiple statements being edited -- isolate the current one by
Expand Down
1 change: 1 addition & 0 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def checklist(questions):

checks = ['Have you created the debian package?',
'Have you updated the AUTHORS file?',
'Have you updated the `Usage` section of the README?',
]
checklist(checks)

Expand Down

0 comments on commit cdbc7cd

Please sign in to comment.