How to import md from gitbook to showdoc - gitbook

I currently have a lot of gitbook md files, I want to import these gitbook md files into showdoc ,is there any way to import these files into showdoc?

Related

What's the best way to import large python modules into a ROS package? - import errors python ROS

I want to include a large python package: Yolov7-https://github.com/WongKinYiu/yolov7.git into my already existing ROS package. The large python package consists of many files which depend on each other. I want this to be included and available for use in my main program scripts/main.py, which runs as a ROS node.
File structure: https://imgur.com/a/THP5WvP
PROBLEM: Files in yolov7 importing other files in yolov7 need to have the pathname package.yolov7.file_name, while the whole package is actually written on the form: from file_name import ...
How can I make sure files in yolov7 actually can import other files in yolov7 without having to add the extra path to every import?
Example: instead of having to write: from package.yolov7.utils.datasets import letterbox
I want to be able to have: from utils.datasets import letterbox
I have tried editing CMakeLists.txt, setup.py, and package.xml, but for now they are unchanged in regards to yolov7.
I'm using ROS Noetic, running Ubuntu 5.4.123.

Cannot import functions in from one directory's subfolder to other pyhton files in same parent directories sub folders. How do I use init.py files

parent_folder /
subfolder1 /
subsubfolder1/
a.py
b.py
subsubfolder2/
c.py
d.py
e.py
subfolder2 /
subsubfolder2/
f.py
g.py
subfolder3 /
h.py
i.py
g.py
I want to import the functions from files h,i,g to all the subsubfolders py files. Can any one help me how do I do that.
I have tried using sys.path.insert(0 , 'path')
from h import funct1 , from g import funct1. It works
II get this error ImportError: attempted relative import with no known parent package when I do from .h import funct1 and I also want to Implement this in docker files. Is there any other way?
Thanks in advance !!
For your case it is best to use sys:-
for example to import in a.py use:
import sys
sys.path.insert(0,'../../subfolder3')
import h,i,g
Here we can use relative path in sys, '..' indicates moving one folder back
For Docker it is best to use relative path as:
import sys,os
sys.path.append(os.path.join(sys.path[0],'../../subfolder3'))
import h,i,g
This would work for docker. Please try and let me know if it works.

How to create a folder of current date and time And copy some other folder in that recently made folder in python

I have tried it in Jetbrains Pycharm but it is showing an error.
Here is my code
from datetime import datetime
import os
import shutil
now = datetime.now()
dt=now.strftime("%d%m%Y %H%M%S")
os.mkdir(dt)
shutil.copytree(r"C:\Users\Computer\PycharmProjects\06\08",r"C:\Users\Computer\PycharmProjects\Filecopy\dt")
If you are trying to use the path of your newly-created directory, the line should do:
..., r"C:\Users\Computer\PycharmProjects\Filecopy\{}".format(dt))

Is there any method to add multiple files to data_files in a setup file automatically created by py2app?

I'm a newbie in python and programming in general. Recently I've made a small card game using pygame library and now I want to have a standalone app executable on Mac. I'm using py2app to do so. Unfortunately, I have some issues with adding files into data_files when editing a setup file, created automatically by py2app. I have about 60 .png files, located in two folders. Is there any way to load them into the setup file automatically? Or I have to do it manually? Also, I can't figure out where in the setup file I can add the location directory of these files.
Here is the code:
from setuptools import setup
APP = ['Blackjack.py']
DATA_FILES = []
OPTIONS = {}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Thank you in advance!
Try this. I haven't tested it yet, but it should work. In your data files just add this instead of the files: [*f1_files, *f2_files]
import os
FOLDER_1 = "Path/To/Your/First/Folder"
FOLDER_2 = "Path/To/Your/Second/Folder"
f1_files = [os.path.join(FOLDER_1, file) for file in os.listdir(FOLDER_1)]
f2_files = [os.path.join(FOLDER_2, file) for file in os.listdir(FOLDER_2)]

shutil.rmtree does not remove directory

I'm struggling with one error for few hours now. I'm making a setup.exe for my program. Each time I install it I want old dirs and files to be removed and created again. The code I use for that is:
import os
import shutil
data_path = os.path.join(os.environ['HOMEDRIVE'], '\ProgramData', 'MyDir')
shutil.rmtree(data_path, ignore_errors=True)
os.makedirs(data_path)
When I run this I see an error <FileExists> You can not create file that already exists: 'C:\\ProgramData\\MyDir'

Resources