From 4dfd75eb3e70766f20cb0dffeb99a584350280ad Mon Sep 17 00:00:00 2001 From: Mark Aron Szulyovszky Date: Mon, 7 Nov 2022 17:00:11 +0100 Subject: [PATCH] chore(Project): removed code that was used to "close-source" the repo --- .libcst.codemod.yaml | 35 ------------- environment-strip-action.yaml | 13 ----- mycodemod/__init__.py | 1 - mycodemod/replace_functions.py | 90 ---------------------------------- strip_action.yaml | 13 ----- 5 files changed, 152 deletions(-) delete mode 100644 .libcst.codemod.yaml delete mode 100644 environment-strip-action.yaml delete mode 100644 mycodemod/__init__.py delete mode 100644 mycodemod/replace_functions.py delete mode 100644 strip_action.yaml diff --git a/.libcst.codemod.yaml b/.libcst.codemod.yaml deleted file mode 100644 index 4e29fa6..0000000 --- a/.libcst.codemod.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# String that LibCST should look for in code which indicates that the - -# module is generated code. - -generated_code_marker: '@generated' - -# Command line and arguments for invoking a code formatter. Anything - -# specified here must be capable of taking code via stdin and returning - -# formatted code via stdout. - -formatter: ['black', '-'] - -# List of regex patterns which LibCST will evaluate against filenames to - -# determine if the module should be touched. - -blacklist_patterns: ['.*replace_functions\.py'] - -# List of modules that contain codemods inside of them. - -modules: - -- 'libcst.codemod.commands' -- 'mycodemod' - -# Absolute or relative path of the repository root, used for providing - -# full-repo metadata. Relative paths should be specified with this file - -# location as the base. - -repo_root: '.' - diff --git a/environment-strip-action.yaml b/environment-strip-action.yaml deleted file mode 100644 index cf548fd..0000000 --- a/environment-strip-action.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: strip -channels: - - johnsnowlabs - - conda-forge - - defaults - - ml4t - - ranaroussi -dependencies: - - python=3.9 - - pip: - - black - - libcst -prefix: /usr/local/anaconda3/envs/strip diff --git a/mycodemod/__init__.py b/mycodemod/__init__.py deleted file mode 100644 index 8b13789..0000000 --- a/mycodemod/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/mycodemod/replace_functions.py b/mycodemod/replace_functions.py deleted file mode 100644 index 8c2f6f3..0000000 --- a/mycodemod/replace_functions.py +++ /dev/null @@ -1,90 +0,0 @@ -import argparse -from ast import Expression, literal_eval -from typing import Union - -import libcst as cst -from libcst.codemod import CodemodContext, VisitorBasedCodemodCommand -from libcst.codemod.visitors import AddImportsVisitor - - -class ReplaceFunctionCommand(VisitorBasedCodemodCommand): - - # Add a description so that future codemodders can see what this does. - DESCRIPTION: str = "Replaces the body of a function with pass." - - def __init__(self, context: CodemodContext) -> None: - # Initialize the base class with context, and save our args. Remember, the - # "dest" for each argument we added above must match a parameter name in - # this init. - super().__init__(context) - - def leave_FunctionDef( - self, original_node: cst.FunctionDef, updated_node: cst.FunctionDef - ) -> cst.FunctionDef: - functions_docstring = updated_node.get_docstring() - docstring_should_be = '"""No docstring here yet."""' - if functions_docstring is not None: - docstring_should_be = '"""\n{}\n\n"""'.format(functions_docstring) - - replace_function = cst.FunctionDef( - name=updated_node.name, - params=updated_node.params, # cst.Parameters(), - body=cst.IndentedBlock( - body=[ - cst.SimpleStatementLine( - body=[ - cst.Expr( - value=cst.SimpleString( - value=docstring_should_be, - lpar=[], - rpar=[], - ), - semicolon=cst.MaybeSentinel.DEFAULT, - ), - ], - leading_lines=[], - trailing_whitespace=cst.TrailingWhitespace( - whitespace=cst.SimpleWhitespace( - value="", - ), - comment=None, - newline=cst.Newline( - value=None, - ), - ), - ), - cst.SimpleStatementLine( - body=[ - cst.Pass(), - ], - ), - ] - ), - ) - - return replace_function - - def leave_ClassDef( - self, original_node: cst.ClassDef, updated_node: cst.ClassDef - ) -> cst.ClassDef: - new_body = [] - for body_item in updated_node.body.body: - if type(body_item) is cst.FunctionDef: - new_body.append(self.leave_FunctionDef(body_item, body_item)) - - return updated_node.with_changes(body=cst.IndentedBlock(new_body)) - - def leave_Module( - self, original_node: cst.Module, updated_node: cst.Module - ) -> cst.Module: - new_module_body = [] - for node in original_node.body: - if type(node) is cst.FunctionDef: - new_module_body.append(self.leave_FunctionDef(node, node)) - - if type(node) is cst.ClassDef: - new_module_body.append(self.leave_ClassDef(node, node)) - - replace_function = cst.Module(body=new_module_body) - - return replace_function diff --git a/strip_action.yaml b/strip_action.yaml deleted file mode 100644 index 89ddf00..0000000 --- a/strip_action.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: strip -channels: - - johnsnowlabs - - conda-forge - - defaults - - ml4t - - ranaroussi -dependencies: - - python=3.9 - - pip: - - black - - libcst -prefix: /usr/local/anaconda3/envs/strip \ No newline at end of file