python code
This commit is contained in:
parent
13ce480fac
commit
d26b956c15
|
@ -0,0 +1,27 @@
|
|||
from setuptools import setup, Extension
|
||||
import platform
|
||||
|
||||
extra_compile_args = []
|
||||
extra_link_args = []
|
||||
|
||||
# Set C++17 flag based on the compiler
|
||||
if platform.system() == "Windows":
|
||||
extra_compile_args.append('/std:c++17')
|
||||
else:
|
||||
extra_compile_args.append('-std=c++17')
|
||||
|
||||
tree_structurer_module = Extension(
|
||||
'tree_structurer._tree_structurer',
|
||||
sources=['tree_structurer/cpp/bindings.cpp', 'tree_structurer/cpp/tree_structurer.cpp'],
|
||||
include_dirs=['tree_structurer/cpp'],
|
||||
extra_compile_args=extra_compile_args,
|
||||
extra_link_args=extra_link_args,
|
||||
)
|
||||
|
||||
setup(
|
||||
name='tree_structurer',
|
||||
version='0.0.2',
|
||||
description='A module for analyzing directory structures',
|
||||
ext_modules=[tree_structurer_module],
|
||||
packages=['tree_structurer'],
|
||||
)
|
|
@ -0,0 +1 @@
|
|||
from tree_structurer._tree_structurer import create_tree_structurer, get_structure
|
|
@ -0,0 +1,31 @@
|
|||
import os
|
||||
import sys
|
||||
import argparse
|
||||
from tree_structurer import create_tree_structurer, get_structure
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Display directory structure in a tree-like format')
|
||||
parser.add_argument('path', nargs='?', default=os.getcwd(),
|
||||
help='Path to analyze (default: current directory)')
|
||||
parser.add_argument('-v', '--verbose', action='store_true',
|
||||
help='Show more detailed output')
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
if args.verbose:
|
||||
print(f"Analyzing directory: {args.path}")
|
||||
|
||||
# Create tree structurer instance
|
||||
create_tree_structurer()
|
||||
|
||||
# Get and print structure
|
||||
structure = get_structure(args.path)
|
||||
for line in structure:
|
||||
print(line)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue