Code Monkey home page Code Monkey logo

sloc's People

Contributors

dandigit avatar umbralreaper avatar

Watchers

 avatar

Forkers

umbralreaper

sloc's Issues

Check if file is plain text

@Dandigit

If I use all in a directory that contains png files, It comes up with an error message
"Traceback (most recent call last):
File "sloc.py", line 58, in
totalLines = getTotalLines(getFlags())
File "sloc.py", line 54, in getTotalLines
totalLines += countLinesInFile(os.path.join(root, file))
File "sloc.py", line 38, in countLinesInFile
for i, l in enumerate(file):
File "C:\Users\bpassaportis\AppData\Local\Programs\Python\Python37-32\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 144: character maps to "
.
I know you could probably us python-magic to work out whether any given file is plain text. Example Here.
I know I could specify all the file types that I want to, but this could be a problem for someone who has hundreds of different types of files in a directory.

  • SimpleBinary

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.