mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-08-22 22:34:01 -07:00
fix flake8 issues
This commit is contained in:
parent
a883abc2f0
commit
bc512fcc1d
1 changed files with 62 additions and 58 deletions
32
build.py
32
build.py
|
@ -1,24 +1,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from pybuilder.core import *
|
||||
from pybuilder.core import task, dependents, depends, use_plugin, init
|
||||
from enum import Enum
|
||||
import glob
|
||||
import shutil
|
||||
import warnings
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
use_plugin("python.core")
|
||||
#use_plugin("python.unittest")
|
||||
# use_plugin("python.unittest")
|
||||
use_plugin("python.flake8")
|
||||
use_plugin("python.coverage")
|
||||
use_plugin("exec")
|
||||
|
||||
name = "youtube-dl"
|
||||
default_task = ["clean","build"]
|
||||
default_task = ["clean", "build"]
|
||||
version = "0.0.0"
|
||||
|
||||
OS = Enum('OS',['Linux','MacOS', 'Windows'])
|
||||
OS = Enum('OS', ['Linux', 'MacOS', 'Windows'])
|
||||
|
||||
|
||||
@init
|
||||
|
@ -26,7 +25,7 @@ def set_properties(project):
|
|||
project.set_property("dir_source_main_python", "youtube_dl")
|
||||
project.set_property("dir_source_unittest_python", "test")
|
||||
project.set_property("dir_source_main_scripts", "devscripts")
|
||||
#project.set_property("unittest_module_glob", "test*")
|
||||
# project.set_property("unittest_module_glob", "test*")
|
||||
project.set_property('coverage_break_build', False)
|
||||
sys.path.append("./youtube_dl")
|
||||
from version import __version__
|
||||
|
@ -49,6 +48,7 @@ def delete(logger, path):
|
|||
elif (os.path.isdir(path)):
|
||||
shutil.rmtree(path)
|
||||
|
||||
|
||||
@task
|
||||
def clean(logger, project):
|
||||
delete_patterns = [
|
||||
|
@ -103,7 +103,7 @@ def clean(logger, project):
|
|||
|
||||
|
||||
@task
|
||||
## build for the current operating system
|
||||
# build for the current operating system
|
||||
def build(logger, project):
|
||||
if (project.os == OS.Linux or project.os == OS.MacOS):
|
||||
buildUnix(logger, project)
|
||||
|
@ -120,6 +120,7 @@ def mkdir_p(path):
|
|||
except FileExistsError:
|
||||
pass
|
||||
|
||||
|
||||
@task
|
||||
@dependents("installUnix")
|
||||
def buildUnix(logger, project):
|
||||
|
@ -129,14 +130,15 @@ def buildUnix(logger, project):
|
|||
"youtube_dl", "youtube_dl/downloader", "youtube_dl/extractor", "youtube_dl/postprocessor"
|
||||
]
|
||||
for dir in source_dirs:
|
||||
mkdir_p("zip/"+dir)
|
||||
subprocess.run("cp -pPr "+dir+"/*.py zip/"+dir+"/", shell=True)
|
||||
mkdir_p("zip/" + dir)
|
||||
subprocess.run("cp -pPr " + dir + "/*.py zip/" + dir + "/", shell=True)
|
||||
subprocess.run("touch -t 200001010101 zip/youtube_dl/*.py zip/youtube_dl/*/*.py", shell=True)
|
||||
subprocess.run("mv zip/youtube_dl/__main__.py zip/",shell=True)
|
||||
subprocess.run("cd zip ; zip -q ../youtube-dl youtube_dl/*.py youtube_dl/*/*.py __main__.py",shell=True)
|
||||
subprocess.run("mv zip/youtube_dl/__main__.py zip/", shell=True)
|
||||
subprocess.run("cd zip ; zip -q ../youtube-dl youtube_dl/*.py youtube_dl/*/*.py __main__.py", shell=True)
|
||||
subprocess.run("rm -rf zip", shell=True)
|
||||
subprocess.run("echo '#!/usr/bin/env python' > youtube-dl ; cat youtube-dl.zip >> youtube-dl ; rm youtube-dl.zip; chmod a+x youtube-dl", shell=True)
|
||||
|
||||
|
||||
@task
|
||||
@depends("buildUnix")
|
||||
def installUnix(logger, project):
|
||||
|
@ -144,7 +146,7 @@ def installUnix(logger, project):
|
|||
BINDIR = f"{PREFIX}/bin"
|
||||
MANDIR = f"{PREFIX}/man"
|
||||
SHAREDIR = f"{PREFIX}/share"
|
||||
#SYSCONFDIR = f"$(shell if [ $(PREFIX) = /usr -o $(PREFIX) = /usr/local ]; then echo /etc; else echo $(PREFIX)/etc; fi)
|
||||
# SYSCONFDIR = f"$(shell if [ $(PREFIX) = /usr -o $(PREFIX) = /usr/local ]; then echo /etc; else echo $(PREFIX)/etc; fi)
|
||||
SYSCONFDIR = ""
|
||||
|
||||
DESTDIR = ""
|
||||
|
@ -161,12 +163,14 @@ def installUnix(logger, project):
|
|||
install -m 644 youtube-dl.fish {DESTDIR}{SYSCONFDIR}/fish/completions/youtube-dl.fish",
|
||||
shell=True)
|
||||
|
||||
|
||||
@task
|
||||
def buildWin32(logger, project):
|
||||
subprocess.run("python -m setup.py py2exe")
|
||||
|
||||
|
||||
@task
|
||||
def offlinetest(logger,project):
|
||||
def offlinetest(logger, project):
|
||||
res = subprocess.run("python -m nose --verbose test \
|
||||
--exclude test_age_restriction.py \
|
||||
--exclude test_download.py \
|
||||
|
@ -180,6 +184,7 @@ def offlinetest(logger,project):
|
|||
if (res.returncode != 0):
|
||||
sys.exit(res.returncode)
|
||||
|
||||
|
||||
@task
|
||||
def test(logger, project):
|
||||
res = subprocess.run("nosetests --with-coverage \
|
||||
|
@ -190,4 +195,3 @@ def test(logger, project):
|
|||
shell=True)
|
||||
if (res.returncode != 0):
|
||||
sys.exit(res.returncode)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue