Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to use regular expression to more robustly infer file type #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions qvdfile/qvdfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import os, datetime, time
import os, datetime, time, re
from bitstring import BitArray, BitStream, pack

from qvdfile.xml2dict import xml2dict
Expand All @@ -22,7 +22,7 @@ def __init__(self,name):
which extracts metadata section from QVD file and clears necessary data (e.g. number of rows is unknown),
this tool is also capable of creating XML template with just one field. """

self.mode = os.O_RDONLY if os.path.split(name)[1].split('.')[1].lower()=='qvd' else os.O_WRONLY
self.mode = os.O_RDONLY if re.match('^.*qvd$', name, re.IGNORECASE) else os.O_WRONLY

""" We never ever want to erase exisitng QVD file, so we check QVD file presence and raise
exception if it exists """
Expand Down