jojonas / pyedid Goto Github PK
View Code? Open in Web Editor NEWPython library to parse extended display identification data (EDID)
License: MIT License
Python library to parse extended display identification data (EDID)
License: MIT License
Windows上使用to_csv出现编码错误
def to_csv(self, csv_path: str):
"""Dump registry to csv file"""
with open(csv_path, "w") as csv_file:
writer = csv.writer(csv_file)
writer.writerows(self.items())
return self
建议增加encoding="utf-8",修改后
def to_csv(self, csv_path: str):
"""Dump registry to csv file"""
with open(csv_path, "w", encoding="utf-8") as csv_file:
writer = csv.writer(csv_file)
writer.writerows(self.items())
return self
以及 from_csv
Hi and thanks for the script. Just though I'd post a script for updating the pnp_id.csv
CSV.
foo@bar ~ $ python /path/to/script.py > /path/to/pnp_id.csv
See python /path/to/script.py --help
for more options. Requires BeautifulSoup4 and requests.
import csv
import datetime
import os.path
import shutil
import sys
from argparse import ArgumentParser
from contextlib import suppress
from pathlib import Path
from bs4 import BeautifulSoup
import requests
def log(*args, **kwargs):
return print(*args, file=sys.stderr, **kwargs)
def main():
# Parse command line arguments
log('Parsing command line arguments')
parser = ArgumentParser()
parser.add_argument('-c', '--clear-cache', action='store_true',
default=False)
parser.add_argument('-a', '--include-approved', action='store_true',
default=False)
parser.add_argument('-u', '--url',
default='https://www.uefi.org/pnp_id_list')
parser.add_argument('cache', nargs='?', default='~/.cache/edid')
args = parser.parse_args()
args.cache = Path(os.path.expanduser(args.cache)).absolute()
# Prepare cache
if args.clear_cache:
log(f'Clearing cache {args.cache}')
shutil.rmtree(args.cache)
log(f'Ensuring cache {args.cache}')
args.cache.mkdir(parents=True, exist_ok=True)
# Load HTML from cache or the web
html_path = args.cache / 'src.html'
if html_path.exists():
log(f'Loading cached HTML from {html_path}')
html = html_path.read_text()
else:
log(f'Downloading HTML from {args.url}')
response = requests.get(args.url)
html = response.text
with html_path.open('w') as html_file:
html_file.write(html)
# Extract data from HTML
log(f'Extracting data from HTML')
soup = BeautifulSoup(html, 'html5lib')
rows = []
for tr in soup.find('tbody').find_all('tr'):
name_td, pnp_id_td, approved_td = tr.find_all('td')
name = name_td.text.strip()
pnp_id = pnp_id_td.text.strip()
row = [pnp_id, name]
if args.include_approved:
approved = datetime.datetime.strptime(approved_td.text.strip(),
'%m/%d/%Y').date()
row.append(approved)
rows.append(row)
# Write CSV file
log(f'Writing CSV file')
rows.sort()
csv.writer(sys.stdout).writerows(rows)
sys.stdout.close()
if __name__ == '__main__':
with suppress(KeyboardInterrupt):
main()
The "Standard timing" resolutions are not shown correctly, since the bitwise detection (line 151) is incorrect.
Can you replace:
bit = raw_edid.timings_supported & 1
With this:
bit = raw_edid.timings_supported & (1 << i)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.