mirror of https://github.com/vitalif/phantomjs
Use phantom.scriptName instead of phantom.args[0]
parent
fb99a4868d
commit
61459fab45
|
@ -130,6 +130,10 @@ class Phantom(QObject):
|
|||
def scriptLookupDir(self, dirPath):
|
||||
self.m_page.scriptLookupDir = dirPath
|
||||
|
||||
@pyqtProperty(str)
|
||||
def scriptName(self):
|
||||
return os.path.basename(self.m_scriptFile)
|
||||
|
||||
@pyqtProperty('QVariantMap')
|
||||
def version(self):
|
||||
version = {
|
||||
|
|
|
@ -77,8 +77,6 @@ def parseArgs(args):
|
|||
if not os.path.exists(args.script):
|
||||
sys.exit('No such file or directory: \'%s\'' % args.script)
|
||||
|
||||
args.script_args.insert(0, os.path.basename(args.script))
|
||||
|
||||
return args
|
||||
|
||||
|
||||
|
|
|
@ -142,7 +142,6 @@ Phantom::Phantom(QObject *parent)
|
|||
}
|
||||
|
||||
// The remaining arguments are available for the script.
|
||||
m_args += QFileInfo(m_scriptFile).fileName();
|
||||
while (argIterator.hasNext()) {
|
||||
const QString &arg = argIterator.next();
|
||||
m_args += arg;
|
||||
|
@ -242,3 +241,8 @@ void Phantom::setScriptLookupDir(const QString &dirPath)
|
|||
{
|
||||
m_page->setScriptLookupDir(dirPath);
|
||||
}
|
||||
|
||||
QString Phantom::scriptName() const
|
||||
{
|
||||
return QFileInfo(m_scriptFile).fileName();
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ class Phantom: public QObject
|
|||
Q_PROPERTY(QStringList args READ args)
|
||||
Q_PROPERTY(QVariantMap defaultPageSettings READ defaultPageSettings)
|
||||
Q_PROPERTY(QString scriptLookupDir READ scriptLookupDir WRITE setScriptLookupDir)
|
||||
Q_PROPERTY(QString scriptName READ scriptName)
|
||||
Q_PROPERTY(QVariantMap version READ version)
|
||||
|
||||
public:
|
||||
|
@ -58,6 +59,8 @@ public:
|
|||
QString scriptLookupDir() const;
|
||||
void setScriptLookupDir(const QString &dirPath);
|
||||
|
||||
QString scriptName() const;
|
||||
|
||||
QVariantMap version() const;
|
||||
|
||||
public slots:
|
||||
|
|
Loading…
Reference in New Issue