Skip to content

Commit 2a6ce8d

Browse files
committed
Get files list in directory and check if one line is an inline comment in python syntax
1 parent f74fbbc commit 2a6ce8d

5 files changed

Lines changed: 121 additions & 0 deletions

File tree

‎zeyue/0007/.ropeproject/config.py‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# The default ``config.py``
2+
3+
4+
def set_prefs(prefs):
5+
"""This function is called before opening the project"""
6+
7+
# Specify which files and folders to ignore in the project.
8+
# Changes to ignored resources are not added to the history and
9+
# VCSs. Also they are not returned in `Project.get_files()`.
10+
# Note that ``?`` and ``*`` match all characters but slashes.
11+
# '*.pyc': matches 'test.pyc' and 'pkg/test.pyc'
12+
# 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc'
13+
# '.svn': matches 'pkg/.svn' and all of its children
14+
# 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o'
15+
# 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o'
16+
prefs['ignored_resources'] = [
17+
'*.pyc', '*~', '.ropeproject', '.hg', '.svn', '_svn', '.git',
18+
'__pycache__', '.tox', '.env', 'node_modules', 'bower_components']
19+
20+
# Specifies which files should be considered python files. It is
21+
# useful when you have scripts inside your project. Only files
22+
# ending with ``.py`` are considered to be python files by
23+
# default.
24+
#prefs['python_files'] = ['*.py']
25+
26+
# Custom source folders: By default rope searches the project
27+
# for finding source folders (folders that should be searched
28+
# for finding modules). You can add paths to that list. Note
29+
# that rope guesses project source folders correctly most of the
30+
# time; use this if you have any problems.
31+
# The folders should be relative to project root and use '/' for
32+
# separating folders regardless of the platform rope is running on.
33+
# 'src/my_source_folder' for instance.
34+
#prefs.add('source_folders', 'src')
35+
36+
# You can extend python path for looking up modules
37+
#prefs.add('python_path', '~/python/')
38+
39+
# Should rope save object information or not.
40+
prefs['save_objectdb'] = True
41+
prefs['compress_objectdb'] = False
42+
43+
# If `True`, rope analyzes each module when it is being saved.
44+
prefs['automatic_soa'] = True
45+
# The depth of calls to follow in static object analysis
46+
prefs['soa_followed_calls'] = 0
47+
48+
# If `False` when running modules or unit tests "dynamic object
49+
# analysis" is turned off. This makes them much faster.
50+
prefs['perform_doa'] = True
51+
52+
# Rope can check the validity of its object DB when running.
53+
prefs['validate_objectdb'] = True
54+
55+
# How many undos to hold?
56+
prefs['max_history_items'] = 32
57+
58+
# Shows whether to save history across sessions.
59+
prefs['save_history'] = True
60+
prefs['compress_history'] = False
61+
62+
# Set the number spaces used for indenting. According to
63+
# :PEP:`8`, it is best to use 4 spaces. Since most of rope's
64+
# unit-tests use 4 spaces it is more reliable, too.
65+
prefs['indent_size'] = 4
66+
67+
# Builtin and c-extension modules that are allowed to be imported
68+
# and inspected by rope.
69+
prefs['extension_modules'] = []
70+
71+
# Add all standard c-extensions to extension_modules list.
72+
prefs['import_dynload_stdmods'] = True
73+
74+
# If `True` modules with syntax errors are considered to be empty.
75+
# The default value is `False`; When `False` syntax errors raise
76+
# `rope.base.exceptions.ModuleSyntaxError` exception.
77+
prefs['ignore_syntax_errors'] = False
78+
79+
# If `True`, rope ignores unresolvable imports. Otherwise, they
80+
# appear in the importing namespace.
81+
prefs['ignore_bad_imports'] = False
82+
83+
84+
def project_opened(project):
85+
"""This function is called after opening the project"""
86+
# Do whatever you like here!
33 Bytes
Binary file not shown.

‎zeyue/0007/.ropeproject/history‎

14 Bytes
Binary file not shown.

‎zeyue/0007/.ropeproject/objectdb‎

6 Bytes
Binary file not shown.

‎zeyue/0007/ComputeCodeLines.py‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Compute the line number of codes in one directory
2+
3+
import os
4+
5+
6+
def getFilesList(directory):
7+
file_paths = []
8+
9+
for root, directories, files in os.walk(directory):
10+
for filename in files:
11+
file_path = os.path.join(root, filename)
12+
file_paths.append(file_path)
13+
14+
return file_paths
15+
16+
full_file_paths = getFilesList("D:/PythonProjects/python")
17+
# print("\n".join(full_file_paths))
18+
19+
file_type = "python"
20+
inline_comment_syntax = "#"
21+
22+
23+
def isInlineComment(string_line):
24+
"""This function will check if input line is a comment or not.
25+
26+
:string_line: input line
27+
:returns: true or false
28+
29+
"""
30+
if string_line[0] == inline_comment_syntax:
31+
return True
32+
else:
33+
return False
34+
35+
# print(isInlineComment("# this is a test"))

0 commit comments

Comments
 (0)