-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from pomponchik/develop
0.0.22
- Loading branch information
Showing
17 changed files
with
241 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
coverage: | ||
status: | ||
project: | ||
default: | ||
threshold: 80% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ test.py | |
.coverage.* | ||
tests/cli/data/chpok | ||
tests/cli/data/pok | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,39 @@ | ||
from functools import lru_cache | ||
|
||
from instld.errors import InstallingPackageError | ||
from instld.state_management.storage import state_storage, RunType | ||
|
||
|
||
def get_comment_substring_from_string(string): | ||
splitted_line = string.split('#') | ||
right_part = splitted_line[1:] | ||
right_part = '#'.join(right_part) | ||
right_part = right_part.strip() | ||
if right_part.startswith('instld:'): | ||
right_part = right_part[7:].strip() | ||
if right_part: | ||
return right_part | ||
else: | ||
raise InstallingPackageError('An empty list of options in the comment.') | ||
|
||
@lru_cache() | ||
def get_comment_string_from_file(line_number, file_name): | ||
try: | ||
with open(file_name, 'r') as file: | ||
for index, line in enumerate(file): | ||
if index + 1 == line_number: | ||
splitted_line = line.split('#') | ||
right_part = splitted_line[1:] | ||
right_part = '#'.join(right_part) | ||
right_part = right_part.strip() | ||
if right_part.startswith('instld:'): | ||
right_part = right_part[7:].strip() | ||
if right_part: | ||
return right_part | ||
else: | ||
raise InstallingPackageError('An empty list of options in the comment.') | ||
break | ||
return get_comment_substring_from_string(line) | ||
|
||
except (FileNotFoundError, OSError): | ||
return None | ||
|
||
def get_comment_string(frame): | ||
line_number = frame.f_lineno | ||
code = frame.f_code | ||
file_name = code.co_filename | ||
def get_comment_string_by_frame(frame): | ||
if state_storage.run_type == RunType.script: | ||
line_number = frame.f_lineno | ||
code = frame.f_code | ||
file_name = code.co_filename | ||
|
||
return get_comment_string_from_file(line_number, file_name) | ||
|
||
return get_comment_string_from_file(line_number, file_name) | ||
elif state_storage.run_type == RunType.REPL: | ||
return get_comment_substring_from_string(state_storage.last_string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.