How to use make_package_index method in Behave

Best Python code snippet using behave

make_localpi.py

Source:make_localpi.py Github

copy

Full Screen

...143 packages = "\n".join(parts)144 text = index_template.format(title=package.name, packages=packages)145 f.write(text.strip())146 f.close()147def make_package_index(download_dir):148 """149 Create a pypi server like file structure below download directory.150 :param download_dir: Download directory with packages.151 EXAMPLE BEFORE:152 +-- downloads/153 +-- alice-1.0.zip154 +-- alice-1.0.tar.gz155 +-- bob-1.3.0.tar.gz156 +-- bob-1.4.2.tar.gz157 +-- charly-1.0.tar.bz2158 EXAMPLE AFTERWARDS:159 +-- downloads/160 +-- simple/161 | +-- alice/index.html --> ../../alice-*.*162 | +-- bob/index.html --> ../../bob-*.*163 | +-- charly/index.html --> ../../charly-*.*164 | +-- index.html --> alice/index.html, bob/index.html, ...165 +-- alice-1.0.zip166 +-- alice-1.0.tar.gz167 +-- bob-1.3.0.tar.gz168 +-- bob-1.4.2.tar.gz169 +-- charly-1.0.tar.bz2170 """171 if not os.path.isdir(download_dir):172 raise ValueError("No such directory: %r" % download_dir)173 pkg_rootdir = os.path.join(download_dir, "simple")174 if os.path.isdir(pkg_rootdir):175 shutil.rmtree(pkg_rootdir, ignore_errors=True)176 os.mkdir(pkg_rootdir)177 # -- STEP: Collect all packages.178 package_map = {}179 packages = []180 for filename in sorted(os.listdir(download_dir)):181 if not Package.isa(filename):182 continue183 pkg_filepath = os.path.join(download_dir, filename)184 package_name = Package.get_pkgname(pkg_filepath)185 package = package_map.get(package_name, None)186 if not package:187 # -- NEW PACKAGE DETECTED: Store/register package.188 package = Package(pkg_filepath)189 package_map[package.name] = package190 packages.append(package)191 else:192 # -- SAME PACKAGE: Collect other variant/version.193 package.files.append(pkg_filepath)194 # -- STEP: Make local PYTHON PACKAGE INDEX.195 root_package = Package(None, "Python Package Index")196 root_package.files = [ os.path.join(pkg_rootdir, pkg.name, "index.html")197 for pkg in packages ]198 make_index_for(root_package, pkg_rootdir)199 for package in packages:200 index_dir = os.path.join(pkg_rootdir, package.name)201 make_index_for(package, index_dir)202# -----------------------------------------------------------------------------203# MAIN:204# -----------------------------------------------------------------------------205if __name__ == "__main__":206 if (len(sys.argv) != 2) or "-h" in sys.argv[1:] or "--help" in sys.argv[1:]:207 print("USAGE: %s DOWNLOAD_DIR" % os.path.basename(sys.argv[0]))208 print(__doc__)209 sys.exit(1)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Behave automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful