-
Notifications
You must be signed in to change notification settings - Fork 5
Restructure database and stabilize back-end logic #93
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
Merged
Merged
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
2eb0e68
Add postgres to requirements.txt; Close calebdehaan#92
natiiix d9ba102
Visual tweak: fit longer origin strings on screen
natiiix 2732b7a
Decrease subtree weight threshold in Oxygen
natiiix d5caad9
Switch from raw psycopg2 to postgres package / lib
natiiix f7a3564
Switch from postgres.py to easy-postgres
natiiix 8797e97
Switch postgres for easy-postgres in requirements
natiiix e493937
Remove print, add warning on duplicate repo
natiiix a6efd86
Restructure database to include more info
natiiix 3c719ad
Add "valid" column to repos table
natiiix 7707e3e
Move RepoInfo to its own module
natiiix 4368c7f
Implement RepoInfo parser (from repo path)
natiiix 7d60da8
Implement method to clone / pull repo via RepoInfo
natiiix 025484d
Modify repo path regex to ignore ".git" at the end
natiiix 3f2ecfb
Switch from valid bool to status table
natiiix 2bd998b
Remove old repo cloner module
natiiix 04cfaf0
Add new path handler module for path-related logic
natiiix a91185e
Add check for empty URL params
natiiix 3afb5cf
Remove config import and set up from web app
natiiix ba7a75a
Remove global config module altogether
natiiix 10c2c8f
Remove unused imports; Add missing class reference
natiiix ad46862
Switch to new repo path parsing functions
natiiix 15551f3
Replace old repo cloning code reference with new
natiiix 278178a
Move args_handler and path_handler to CLI module
natiiix 5d24f2b
Update code_duplication mentions to new names
natiiix 8e26f7c
Add docstrings to results modules
natiiix e5607e8
Add docstrings to utils modules
natiiix 63570f7
Fix docstyle in CLI
natiiix 21288fe
Add docstring to web app
natiiix cbac8c5
Fix docstyle in algorithms module
natiiix 7748fca
Add docstring to UserInputError
natiiix 6215a1b
Fix docstyle in node classes
natiiix 93f55ba
Fix docstyle in preprocessing module
natiiix 25b3b34
Fix docstyle in result classes
natiiix 921908d
Fix docstyle in utils module
natiiix 0a4a6bc
Rename "/" web app route from hello()
natiiix 02a8593
Add reminder to fix PatterNode to-str conversion
natiiix 1c3c7d2
Move results towards center of screen
natiiix 02f990d
Make all messages larger
natiiix 2f56dfa
Split invalid state into errors; Impr. commits tab
natiiix 8751ce2
Implement NodeOrigin instead of using plain string
natiiix e1c25a8
Make relative origin file paths less verbose
natiiix 10b8958
Add to-str conversion to RepoInfo
natiiix e2acb66
Switch from raw string to NodeOrigin in TreeNode
natiiix 5ac6754
Rework web app to work with new database layout
natiiix a6cbb90
Remove node ID from NodeOrigin; get it at runtime
natiiix 616ce8e
Change all module names to lower-case / snake_case
natiiix 2b1297d
Update imports to new lower-case module names
natiiix 8289052
Add missing trailing newlines to docstrings
natiiix 5800695
Add docstrings to NodeOrigin
natiiix 8fe30e9
Add package docstrings to algorithms
natiiix 338dfce
Add missing package docstrings to engine
natiiix a0ce2a2
Add missing docstrings to engine/nodes/
natiiix fda89b7
Add ctor docstring to UserInputError
natiiix 85ca144
Add docstring to utils package
natiiix 4bc5822
Partially fix docstrings in Iodine package
natiiix 7f9ce2d
Fix docstrings in Chlorine
natiiix 1a03724
Fix docstrings in Oxygen
natiiix 1865a13
Fix docstrings in nodes package
natiiix fc8288d
Make .json, .err and .log rules more specific
natiiix 83ce041
Add missing periods (.) to printing.py docstrings
natiiix 862edb5
Add missing docstrings to RepoInfo
natiiix 65f0165
Add missing docstrings to CLI package
natiiix f29c721
Fix docstrings in web/ and test/ packages
natiiix 2face4d
Fix linter errors and warnings
natiiix 01f599f
Make UserInputError import absolute
natiiix c1e2654
Add GitHub/GitLab URL sanitization to RepoInfo
natiiix 892fe59
Strip whitespace from repo URL in web app
natiiix 62bf540
Change "representation" class docstring wording
natiiix b900817
Delte iter_tools module #95
natiiix 1495ef8
Replace flatten(); Close calebdehaan#95
natiiix c2b90f0
Cast result of chain.from_iterable to list
natiiix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -4,6 +4,6 @@ | |
| engine/repos/ | ||
| venv/ | ||
| web/credentials.py | ||
| **/*.json | ||
| *.err | ||
| *.log | ||
| clones_*.json | ||
| qa/*.err | ||
| qa/*.log | ||
This file contains hidden or 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 hidden or 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 @@ | ||
| """Package containing implementation of the application's CLI (command line interface).""" |
This file contains hidden or 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 hidden or 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 hidden or 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,75 @@ | ||
| """Module containing functions for handling command-line arguments supplied by the user.""" | ||
|
|
||
| from os.path import isdir | ||
| from engine.errors.user_input import UserInputError | ||
| from engine.preprocessing.repoinfo import RepoInfo | ||
|
|
||
|
|
||
| _USAGE_TEXT = """\ | ||
| Usage: | ||
| python3 -m cli <first repository> <second repository> - Repository comparison mode | ||
| python3 -m cli <repository> - Single repository mode | ||
|
|
||
| Valid repository path formats: | ||
| Short GitHub repository path - username/repository | ||
| Full remote repository path - https://github.com/username/repository | ||
| Absolute or relative local directory path - /home/user/directory""" | ||
|
|
||
|
|
||
| def repo_path_to_local_path(repo_path): | ||
| """ | ||
| Convert a repository path into a local file system path. | ||
|
|
||
| This repository path is extended (compared to the repository path | ||
| used by RepoInfo) by adding support for existing local directories. | ||
|
|
||
| The process typically includes checking for a local directory or | ||
| parsing a full or short repository URL and then cloning the repository. | ||
|
|
||
| Arguments: | ||
| repo_path {string} -- Path of a remote repository or a local directory. | ||
|
|
||
| Returns: | ||
| string -- Path of a local directory equivalent to the one | ||
| specified by the repository path. | ||
| In case of local directories, the paths are equal. | ||
|
|
||
| """ | ||
| if isdir(repo_path): | ||
| return repo_path | ||
|
|
||
| info = RepoInfo.parse_repo_info(repo_path) | ||
|
|
||
| if info and info.clone_or_pull(): | ||
| return info.dir | ||
| else: | ||
| return None | ||
|
|
||
|
|
||
| def handle_args(argv): | ||
| """ | ||
| Check the command line arguments and handles them. | ||
|
|
||
| If there is any problem, an error message will be printed | ||
| and the script will exit with a non-zero exit code. | ||
| If everything goes right, tuple of local repository paths will be returned. | ||
|
|
||
| Arguments: | ||
| argv -- List of command line arguments. | ||
|
|
||
| Returns: | ||
| tuple[string] -- Tuple of local repository paths. | ||
|
|
||
| """ | ||
| if len(argv) == 1 or (len(argv) == 2 and argv[1] in ['-h', '--help', '--usage']): | ||
| # Special case where the usage text is printed using the built-in | ||
| # print function instead of the logging library because | ||
| # the app exits right after the message is displayed. | ||
| print(_USAGE_TEXT) | ||
| raise UserInputError(None, 0) | ||
|
|
||
| if len(argv) < 2 or len(argv) > 3: | ||
| raise UserInputError( | ||
| f"Invalid number of command line arguments: {len(argv) - 1}") | ||
|
|
||
| return tuple(repo_path_to_local_path(a) for a in argv[1:]) | ||
This file contains hidden or 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 @@ | ||
| """Package containing the entire code clone detection engine.""" |
This file contains hidden or 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,3 +1,5 @@ | ||
| """Package containing all implemented clone detection algorithms.""" | ||
|
|
||
| OXYGEN = "oxygen" | ||
| CHLORINE = "chlorine" | ||
| IODINE = "iodine" |
This file contains hidden or 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 hidden or 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 @@ | ||
| """Package containing the Chlorine algorithm and its helper functions.""" |
This file contains hidden or 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 hidden or 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 @@ | ||
| """Package containing the Iodine algorithm and its helper functions.""" |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you might start to accept, that the proposed argparse module might be better approach :)
https://docs.python.org/3.5/library/argparse.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it most certainly is, especially once we begin to allow the user to specify options for the algorithms. I plan on switching to it as soon as I have some tests for the core/engine.