How to roughly transform cpp code structure to python [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Given a project written in C++ with lots of classes (more than a hundred), how to make a rough reimplementation of the code structure?
Edit: as more details are required.
For a project that implements a specific UML Class diagram, I would like to have the same class diagram info generated into Python
Example Source:
my_app
- models
- Company.py (company class)
- Employee.cpp (employee class)
- Laptop.cpp (laptop class)
- Office.cpp (office class)
- common
- utils.cpp (operations and extras classes)
...
Example Output after extraction:
- Company.py
- Employee.py
- Laptop.py
- Office.py
- Operations.py
- Extras.py
Note: As we extract the Class diagram info, generated classes shall contain only the attributes and methods not the implementation

Parse the code with Doxygen and use xml as the output format.
Then use the xml files as input for Langform.

Related

Project structure for a serverless project [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I'm writing a Python project that will be a serverless with 3 handlers:
Get partner contacts;
Get partner deals;
Get partner flows;
Each handler will be based on date range and for each line retrieved on partner calls, it will save into database.
The macro flow would be something like:
-> partner
begin execution -> handler -> service -> end execution
-> databse
Based on that, I have created the following structure:
|my-project
serverless.yaml
|src
|handlers (similar to controllers)
|services
|infrastructure
|database
|partner
|test
|handlers (similar to controllers)
|services
|infrastructure
|database
|partner
Does it make sense? And about the partner functions? It's a single partner, should I create a single partner class with those functions or should I create a single python class for each function?
I see a problem creating a single file because every call needs to create a client - it's something like client = Partner(user, token).
I want to make this project looks great but I don't want to write every single stuff that we have on OOP.

Matching file extension with used programing language [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have a large dataset in a JSON format that contains the file extensions of different programming files. I would like fill the entry "language" with the name of the related programming language in order to make it possible to search the data-set for specific languages. The dataset looks like this:
data = [{"ID":".","doc_path":".","doc_type":".py","language":#insert language here}{"ID":".","doc_path":".","doc_type":".m","language":#insert language here}...]
Is there a way to derive the language name automatically from the doc_type?
There's no built-in mapping object for this in the stdlib. You might be able to find some 3rd-party module that provides it (e.g. on PyPI).

Is it part of clean code to include docstrings in Python? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am working on a project, and I would like to have my code as clean as I can. I am wondering if including docstrings in a class it is considered as clean code or not. For example, one of my class definitions is as follows:
class Hotel:
"""Class to model the rating and rates of a hotel."""
def __init__(self, rating):
"""
:type rating: int
:param rating: hotel rating
"""
self.rating = rating
Is it correct the way I am writing the code, i.e., am I following the clean code standards.
Thanks in advance.
Clean code is partly a matter of opinion. But most of the ones I'm aware of for Python favor including class and method docstrings. For instance, the Google Python Style Guide says:
A function must have a docstring, unless it meets all of the following
criteria:
not externally visible
very short
obvious
...
That said, there's more to good docstrings than just having them; a good place to start is by asking yourself, what would I need to use this class (or function) if I had never seen it before?

How do large static sites make their content effectively searchable? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
One of the most popular tools to generate static sites is Sphinx which is largely used in the Python community to document code. It converts .rst files into other formats like HTML, PDF and others. But how is it possible that a static documentation with plain HTML files is searchable without losing performance?
I guess, it's done by creating an index (like a JSON file for example) that will be loaded via AJAX and is interpreted by something like lunr.js. Since many major projects in the world of Python have a huge documentation (like the Python docs itself). Therefore, how is it possible, to create such a good search without creating a gigantic index file that needs to be loaded?
You can use Google Search Engine to use Google´s power on your site. It is difficult to customize yet powerful. Other reference in this question

Documenting ctypes fields [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I am working on a python module that is a convenience wrapper for a c library. A python Simulation class is simply a ctypes structure with a few additional helper functions. Most parameters in Simulation can just be set using the _fields_ variable. I'm wondering how to document these properly. Should I just add it to the Simulation docstring? Or should I write getter/setter methods just so I can document the variables?
When I do similar things, if it is a small class I will put everything in the same class, but if it is bigger, I typically make a class that only contains the fields, and then a subclass of that with functions. Then you can have a docstring for your fields class and a separate docstring for your simulation functions.
YMMV, but I would never consider adding getters and setters for the sole purpose of making the documentation conform to some real or imaginary ideal.

Categories