-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added compare mode one to one (#131)
- Added support to get repository pull requests information in webparsers; - Logic to color text moved into a separated module. Removed unnecessary libraries; - Initializing some variables moved from run method of the class CodeplagEngine to the constructor; - Functions for getting features now started to splitting into separated module; - Added support one to one check mode.
- Loading branch information
Showing
26 changed files
with
1,202 additions
and
849 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 |
---|---|---|
|
@@ -4,6 +4,8 @@ on: | |
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
paths-ignore: | ||
- 'docs/**' | ||
- '**.md' | ||
|
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
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 was deleted.
Oops, something went wrong.
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
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,40 +1,46 @@ | ||
import os | ||
from pathlib import Path | ||
from typing import List, Optional | ||
|
||
from clang.cindex import Index, TranslationUnit | ||
from clang.cindex import Cursor, Index, TranslationUnit | ||
|
||
from codeplag.cplag.tree import get_features | ||
from codeplag.types import ASTFeatures | ||
|
||
|
||
def get_cursor_from_file(filename, args=None): | ||
def get_cursor_from_file(filepath: Path, | ||
args: Optional[List[str]] = None) -> Optional[Cursor]: | ||
''' | ||
Returns clang.cindex.Cursor object or 0 if file is undefined | ||
Returns clang.cindex.Cursor object or None if file is undefined | ||
@param filename - full path to source file | ||
@param args - list of arguments for clang.cindex.Index.parse() method | ||
''' | ||
|
||
if args is None: | ||
args = [] | ||
|
||
if not os.path.isfile(filename): | ||
print(filename, "Is not a file / doesn't exist") | ||
return 0 | ||
if not filepath.is_file(): | ||
print(filepath, "Is not a file / doesn't exist") | ||
return | ||
|
||
index = Index.create() | ||
options = TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD | ||
|
||
file_obj = index.parse(filename, args=args, options=options) or 0 | ||
file_obj = index.parse(filepath, args=args, options=options) or 0 | ||
|
||
return file_obj.cursor | ||
|
||
|
||
def get_works_from_filepaths(filenames, compile_args): | ||
if not filenames: | ||
def get_works_from_filepaths( | ||
filepaths: List[Path], | ||
compile_args: List[str] | ||
) -> List[ASTFeatures]: | ||
if not filepaths: | ||
return [] | ||
|
||
works = [] | ||
for filename in filenames: | ||
cursor = get_cursor_from_file(filename, compile_args) | ||
features = get_features(cursor, filename) | ||
for filepath in filepaths: | ||
cursor = get_cursor_from_file(filepath, compile_args) | ||
features = get_features(cursor, filepath) | ||
works.append(features) | ||
|
||
return works |
Oops, something went wrong.