Skip to content

Commit

Permalink
merged from origin
Browse files Browse the repository at this point in the history
  • Loading branch information
mapattacker committed Mar 29, 2021
2 parents 4eae479 + a26ce94 commit 22fefca
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 63 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ matrix:
env: TOX_ENV=py34
- python: 2.7
env: TOX_ENV=py27
- python: pypy
env: TOX_ENV=pypy
- python: pypy3
env: TOX_ENV=pypy3
- python: 3.6
env: TOX_ENV=flake8

# Use tox to run tests on Travis-CI to keep one unified method of running tests in any environment
install:
install:
- pip install coverage coveralls tox

# Command to run tests, e.g. python setup.py test
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ Why not pip freeze?
-------------------

- ``pip freeze`` only saves the packages that are installed with ``pip install`` in your environment.
- ``pip freeze`` saves all packages in the environment including those that you don't use in your current project. (if you don't have virtualenv)
- and sometimes you just need to create requirements.txt for a new project without installing modules.
- ``pip freeze`` saves all packages in the environment including those that you don't use in your current project (if you don't have ``virtualenv``).
- and sometimes you just need to create ``requirements.txt`` for a new project without installing modules.
9 changes: 7 additions & 2 deletions pipreqs/mapping
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AFQ:pyAFQ
AG_fft_tools:agpy
ANSI:pexpect
Adafruit:Adafruit_Libraries
Expand All @@ -13,6 +14,7 @@ Crypto:pycryptodome
Cryptodome:pycryptodomex
FSM:pexpect
FiftyOneDegrees:51degrees_mobile_detector_v3_wrapper
functional:pyfunctional
GeoBaseMain:GeoBasesDev
GeoBases:GeoBasesDev
Globals:Zope2
Expand All @@ -22,6 +24,7 @@ Kittens:astro_kittens
Levenshtein:python_Levenshtein
Lifetime:Zope2
MethodObject:ExtensionClass
MySQLdb:MySQL-python
OFS:Zope2
OpenGL:PyOpenGL
OpenSSL:pyOpenSSL
Expand Down Expand Up @@ -592,6 +595,7 @@ devtools:tg.devtools
dgis:2gis
dhtmlparser:pyDHTMLParser
digitalocean:python_digitalocean
discord:discord.py
distribute_setup:ez_setup
distutils2:Distutils2
django:Django
Expand Down Expand Up @@ -675,6 +679,7 @@ geventwebsocket:gevent_websocket
gflags:python_gflags
git:GitPython
github:PyGithub
github3:github3.py
gitpy:git_py
globusonline:globusonline_transfer_api_client
google:protobuf
Expand All @@ -701,7 +706,6 @@ html:pies2overrides
htmloutput:nosehtmloutput
http:pies2overrides
hvad:django_hvad
krbV:krbv
i99fix:199Fix
igraph:python_igraph
imdb:IMDbPY
Expand All @@ -727,6 +731,7 @@ keyczar:python_keyczar
keyedcache:django_keyedcache
keystoneclient:python_keystoneclient
kickstarter:kickstart
krbv:krbV
kss:kss.core
kuyruk:Kuyruk
langconv:AdvancedLangConv
Expand Down Expand Up @@ -798,7 +803,6 @@ msgpack:msgpack_python
mutations:aino_mutations
mws:amazon_mws
mysql:mysql_connector_repackaged
MySQL-python:MySQLdb
native_tags:django_native_tags
ndg:ndg_httpsclient
nereid:trytond_nereid
Expand Down Expand Up @@ -999,6 +1003,7 @@ ruamel:ruamel.base
s2repoze:pysaml2
saga:saga_python
saml2:pysaml2
samtranslator:aws-sam-translator
sass:libsass
sassc:libsass
sasstests:libsass
Expand Down
7 changes: 7 additions & 0 deletions pipreqs/pipreqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ def diff(file_, imports):
def clean(file_, imports):
"""Remove modules that aren't imported in project from file."""
modules_not_imported = compare_modules(file_, imports)

if len(modules_not_imported) == 0:
logging.info("Nothing to clean in " + file_)
return

re_remove = re.compile("|".join(modules_not_imported))
to_write = []

Expand Down Expand Up @@ -453,6 +458,8 @@ def init(args):
imports = local + get_imports_info(difference,
proxy=proxy,
pypi_server=pypi_server)
# sort imports based on lowercase name of package, similar to `pip freeze`.
imports = sorted(imports, key=lambda x: x['name'].lower())

path = (args["--savepath"] if args["--savepath"] else
os.path.join(input_path, "requirements.txt"))
Expand Down
4 changes: 4 additions & 0 deletions tests/_data/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
# Nose
from nose.importer import Importer, add_path, remove_path # loader.py

# see issue #88
import analytics
import flask_seasurf

import atexit
from __future__ import print_function
from docopt import docopt
Expand Down
65 changes: 65 additions & 0 deletions tests/_data_clean/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""unused import"""
# pylint: disable=undefined-all-variable, import-error, no-absolute-import, too-few-public-methods, missing-docstring
import xml.etree # [unused-import]
import xml.sax # [unused-import]
import os.path as test # [unused-import]
from sys import argv as test2 # [unused-import]
from sys import flags # [unused-import]
# +1:[unused-import,unused-import]
from collections import deque, OrderedDict, Counter
# All imports above should be ignored
import requests # [unused-import]

# setuptools
import zipimport # command/easy_install.py

# twisted
from importlib import invalidate_caches # python/test/test_deprecate.py

# astroid
import zipimport # manager.py
# IPython
from importlib.machinery import all_suffixes # core/completerlib.py
import importlib # html/notebookapp.py

from IPython.utils.importstring import import_item # Many files

# pyflakes
# test/test_doctests.py
from pyflakes.test.test_imports import Test as TestImports

# Nose
from nose.importer import Importer, add_path, remove_path # loader.py

# see issue #88
import analytics
import flask_seasurf

import atexit
from __future__ import print_function
from docopt import docopt
import curses, logging, sqlite3
import logging
import os
import sqlite3
import time
import sys
import signal
import bs4
import nonexistendmodule
import boto as b, peewee as p
# import django
import flask.ext.somext # # #
# from sqlalchemy import model
try:
import ujson as json
except ImportError:
import json

import models


def main():
pass

import after_method_is_valid_even_if_not_pep8
Loading

0 comments on commit 22fefca

Please sign in to comment.