comparison PyPlugScanner.cpp @ 58:62dcaa5fe6f8 vampy-2.0

Extended README, added .pyo support
author fazekasgy
date Sun, 11 Oct 2009 09:57:48 +0000
parents 27bab3a16c9a
children 6c755f3e1173
comparison
equal deleted inserted replaced
57:87b9ea6fc7d0 58:62dcaa5fe6f8
79 79
80 vector<string> files = listFiles(m_path[i],"py"); 80 vector<string> files = listFiles(m_path[i],"py");
81 81
82 /// recognise byte compiled plugins 82 /// recognise byte compiled plugins
83 if (getCompiled) { 83 if (getCompiled) {
84 vector<string> compiled_files = listFiles(m_path[i],"pyc"); 84 vector<string> pyc_files = listFiles(m_path[i],"pyc");
85 mergeFileLists(compiled_files,files); 85 vector<string> pyo_files = listFiles(m_path[i],"pyo");
86 mergeFileLists(pyc_files,pyo_files,".pyo");
87 mergeFileLists(pyo_files,files,".py");
86 } 88 }
87 89
88 for (vector<string>::iterator fi = files.begin(); 90 for (vector<string>::iterator fi = files.begin();
89 fi != files.end(); ++fi) { 91 fi != files.end(); ++fi) {
90 string script = *fi; 92 string script = *fi;
111 /// insert python byte code names (.pyc) if a .py file can not be found 113 /// insert python byte code names (.pyc) if a .py file can not be found
112 /// The interpreter automatically generates byte code files and executes 114 /// The interpreter automatically generates byte code files and executes
113 /// them if they exist. Therefore, we prefer .py files, but we allow 115 /// them if they exist. Therefore, we prefer .py files, but we allow
114 /// (relatively) closed source distributions by recognising .pyc files. 116 /// (relatively) closed source distributions by recognising .pyc files.
115 void 117 void
116 PyPlugScanner::mergeFileLists(vector<string> &pyc, vector<string> &py) 118 PyPlugScanner::mergeFileLists(vector<string> &src, vector<string> &tg, string target_ext)
117 { 119 {
118 for (vector<string>::iterator pycit = pyc.begin(); 120 for (vector<string>::iterator srcit = src.begin();
119 pycit != pyc.end(); ++pycit) { 121 srcit != src.end(); ++srcit) {
120 // cerr << *pycit; 122 // cerr << *srcit;
121 string pyc_name = *pycit; 123 string src_name = *srcit;
122 string py_name = pyc_name.substr(0,pyc_name.rfind('.')) + ".py"; 124 string tg_name = src_name.substr(0,src_name.rfind('.')) + target_ext;
123 vector<string>::iterator pyit = find (py.begin(), py.end(), py_name); 125 vector<string>::iterator tgit = find (tg.begin(), tg.end(), tg_name);
124 if (pyit == py.end()) py.push_back(pyc_name); 126 if (tgit == tg.end()) tg.push_back(src_name);
125 } 127 }
126 128
127 } 129 }
128 130
129 131