Comments (5)
From [email protected] on September 13, 2010 08:42:43
Good observation and a nice try at a fix. One problem I see with your approach is that it assumes that the only alpha character in a version number is "b", but I've seen "a", "d", and "v" at least:
1.0a1
2.1d4
1.1v2
But I'm not sure if adding those characters to the list of characters to match is the right approach.
Look at your second example, where the version is detected as "b1" instead of "2.3b1". A worse example would be "Bob2.1", which would be split as "Bo", "b2.1".
Adding more characters to match ("a", "d", "v") would only make this sort of mistake more common.
So, yes, nameAndVersion() can and should be improved. But I think we need to work on the algorithm more...
from munki.
From [email protected] on September 13, 2010 10:24:09
So I did a comparison of "my" nameAndVersion and sahm's, with a few names:
Original: TextWrangler2.3b1
Greg's: Name: TextWrangler Version: 2.3b1
Sahm's: Name: TextWrangler Version: 2.3b1
Original: TextWrangler 2.3 b1
Greg's: Name: TextWrangler 2.3 b Version: 1
Sahm's: Name: TextWrangler 2.3 Version: b1
Original: AdobePhotoshopCS3-11.2.1
Greg's: Name: AdobePhotoshopCS3 Version: 11.2.1
Sahm's: Name: AdobePhotoshopCS3 Version: 11.2.1
Original: MicrosoftOffice2008v12.2.1
Greg's: Name: MicrosoftOffice2008 Version: 12.2.1
Sahm's: Name: MicrosoftOffice2008 Version: 12.2.1
Original: Flip4Mac 2.3.3.3
Greg's: Name: Flip4Mac Version: 2.3.3.3
Sahm's: Name: Flip4Mac Version: 2.3.3.3
Original: TypeIt4Me
Greg's: Name: TypeIt Version: 4Me
Sahm's: Name: TypeIt4Me Version:
Original: Bob2.1
Greg's: Name: Bob Version: 2.1
Sahm's: Name: Bo Version: b2.1
Original: WhizBang-1.0a1
Greg's: Name: WhizBang Version: 1.0a1
Sahm's: Name: WhizBang-1.0a Version: 1
Original: FileMaker Pro 5.0v3
Greg's: Name: FileMaker Pro 5.0 Version: 3
Sahm's: Name: FileMaker Pro 5.0 Version: 3
Original: Phood1.0
Greg's: Name: Phood Version: 1.0
Sahm's: Name: Phood Version: 1.0
With this specific set of names, my version got it "wrong" three times out of ten, sahm's version got it wrong four times out of ten. Two items tripped up both versions. So there's still room for improvement...
Status: Accepted
from munki.
From mikelynn on December 10, 2010 12:50:11
import re
def nameAndVersion(aString):
vSearch = re.compile(r"[0-9vbacd][0-9vbacd.]$")
vSearch2 = re.compile(r"[0-9v][0-9vbacd.]$")
ySearch = re.compile(r"^20[0-9]{2}")
if ("-" in aString):
# Cheat and see if this is the version splitter
possibleVersion = aString[aString.rindex("-")+1:]
possibleName = aString[:aString.rindex("-")]
if (re.match(vSearch, possibleVersion)):
print >> sys.stderr, ('Splitting "%s" to "%s" Version "%s"') % (aString, possibleName, possibleVersion)
return (possibleName, possibleVersion)
if (" " in aString):
# Cheat and see if this is the version splitter
possibleName, possibleVersion, vDone = '','',False
for chunk in (aString.split(" ")[::-1]):
if not vDone:
if (re.match(vSearch, chunk)):
possibleVersion = chunk + " " + possibleVersion
else:
possibleName = chunk + " " + possibleName
vDone = True
else:
possibleName = chunk + " " + possibleName
possibleName = possibleName.strip()
possibleVersion = possibleVersion.strip()
if (possibleVersion):
print >> sys.stderr, ('Splitting "%s" to "%s" Version "%s"') % (aString, possibleName, possibleVersion)
return (possibleName, possibleVersion)
sResult = re.search(vSearch2, aString)
if (sResult):
# String seems to end with a valid version
possibleVersion = sResult.group(0)
if (re.search(ySearch, possibleVersion)):
# Version seems to start with a year, need to split that off
possibleVersion = possibleVersion[4:]
possibleName = aString[:(-1_len(possibleVersion))]
if (possibleVersion):
print >> sys.stderr, ('Splitting "%s" to "%s" Version "%s"') % (aString, possibleName, possibleVersion)
return (possibleName, possibleVersion)
else:
possibleName = aString[:(-1_len(possibleVersion))]
print >> sys.stderr, ('Splitting "%s" to "%s" Version "%s"') % (aString, possibleName, possibleVersion)
return (possibleName, possibleVersion)
# Assume there is no version number
print >> sys.stderr, ('Splitting "%s" to "%s" Version "%s"') % (aString, aString, '')
return (aString, '')
Got a 100% with my version :)
Splitting "TextWrangler2.3b1" to "TextWrangler" Version "2.3b1"
Splitting "TextWrangler 2.3 b1" to "TextWrangler" Version "2.3 b1"
Splitting "AdobePhotoshopCS3-11.2.1" to "AdobePhotoshopCS3" Version "11.2.1"
Splitting "MicrosoftOffice2008v12.2.1" to "MicrosoftOffice2008" Version "v12.2.1"
Splitting "Flip4Mac 2.3.3.3" to "Flip4Mac" Version "2.3.3.3"
Splitting "TypeIt4Me" to "TypeIt4Me" Version ""
Splitting "Bob2.1" to "Bob" Version "2.1"
Splitting "WhizBang-1.0a1" to "WhizBang" Version "1.0a1"
Splitting "FileMaker Pro 5.0v3" to "FileMaker Pro" Version "5.0v3"
Splitting "Phood1.0" to "Phood" Version "1.0"
from munki.
From [email protected] on March 11, 2011 17:22:47
Almost 100% -- ideally I'd want "MicrosoftOffice2008v12.2.1" to split as "MicrosoftOffice2008" Version "12.2.1". A version number should start with a digit at least...
But almost there...
-Greg
from munki.
From [email protected] on May 12, 2011 10:11:05
Changes in r1177 should do a better job of parsing name and version out of a pkg/dmg name. Here's a comparison of the old and new code:
Input: TextWrangler2.3b1
Original nameAndVersion: Name: TextWrangler Version: 2.3b1
New nameAndVersion: Name: TextWrangler Version: 2.3b1
Input: TextWrangler 2.3 b1
Original nameAndVersion: Name: TextWrangler 2.3 b Version: 1
New nameAndVersion: Name: TextWrangler 2.3 b Version: 1
Input: AdobePhotoshopCS3-11.2.1
Original nameAndVersion: Name: AdobePhotoshopCS3 Version: 11.2.1
New nameAndVersion: Name: AdobePhotoshopCS3 Version: 11.2.1
Input: MicrosoftOffice2008v12.2.1
Original nameAndVersion: Name: MicrosoftOffice2008 Version: 12.2.1
New nameAndVersion: Name: MicrosoftOffice2008 Version: 12.2.1
Input: Flip4Mac 2.3.3.3
Original nameAndVersion: Name: Flip4Mac Version: 2.3.3.3
New nameAndVersion: Name: Flip4Mac Version: 2.3.3.3
Input: TypeIt4Me
Original nameAndVersion: Name: TypeIt Version: 4Me
New nameAndVersion: Name: TypeIt4Me Version:
Input: Bob2.1
Original nameAndVersion: Name: Bob Version: 2.1
New nameAndVersion: Name: Bob Version: 2.1
Input: WhizBang-1.0a1
Original nameAndVersion: Name: WhizBang Version: 1.0a1
New nameAndVersion: Name: WhizBang Version: 1.0a1
Input: FileMaker Pro 5.0v3
Original nameAndVersion: Name: FileMaker Pro 5.0 Version: 3
New nameAndVersion: Name: FileMaker Pro Version: 5.0v3
Input: FileMaker Pro v6.0b1
Original nameAndVersion: Name: FileMaker Pro Version: 6.0b1
New nameAndVersion: Name: FileMaker Pro Version: 6.0b1
Input: Phood1.0
Original nameAndVersion: Name: Phood Version: 1.0
New nameAndVersion: Name: Phood Version: 1.0
Input: Expression Media 2
Original nameAndVersion: Name: Expression Media Version: 2
New nameAndVersion: Name: Expression Media Version: 2
Input: ServerAdmin10.5.6v1.1
Original nameAndVersion: Name: ServerAdmin10.5.6 Version: 1.1
New nameAndVersion: Name: ServerAdmin Version: 10.5.6v1.1
Input: WacomTablet_615-2
Original nameAndVersion: Name: WacomTablet_615 Version: 2
New nameAndVersion: Name: WacomTablet_615 Version: 2
Input: MacOSXUpdate10.4.11
Original nameAndVersion: Name: MacOSXUpdate Version: 10.4.11
New nameAndVersion: Name: MacOSXUpdate Version: 10.4.11
Input: Dumb1.0b2a3
Original nameAndVersion: Name: Dumb Version: 1.0b2a3
New nameAndVersion: Name: Dumb Version: 1.0b2a3
Input: TextMate1.2b3-ppc-leopard
Original nameAndVersion: Name: TextMate1.2b3-ppc-leopard Version:
New nameAndVersion: Name: TextMate Version: 1.2b3
Input: iPhoto9.1.3Update
Original nameAndVersion: Name: iPhoto Version: 9.1.3Update
New nameAndVersion: Name: iPhoto Version: 9.1.3
Status: Fixed
Owner: [email protected]
from munki.
Related Issues (20)
- Munki distributed using Intune HOT 1
- Munki manifest pointing to download on CDN? HOT 1
- 6.3 beta crashes on macOS Mojave HOT 6
- Autoremove packages are removed unnecessarily before update HOT 8
- Feature Request: New Built-In Conditional Items based on Contents of ApplicationsInventory.plist HOT 2
- DeprecationWarning in repoclean with Munki 6.3.1 HOT 5
- distutils.version deprecated in Python 3.10 HOT 1
- PyObjC - possibly needs updating to 9.1.1? HOT 3
- munkiimport and makepkginfo crash with distribution-style packages containing a payload-free package HOT 1
- New Optional Key: Pre-warm .apps on macOS Sonoma HOT 6
- Build numbering changed, or digit missing in latest release? HOT 7
- app_usage_monitor fails trying to call superclass's init HOT 4
- [Feature Request] JSON Logging Format HOT 1
- Logic error when processing requires items that fail to download HOT 2
- Minor MSC UI issue - Removing app progress HOT 4
- Option to check for items to install only, 'dry run' HOT 1
- MSC 6.2.1.4599 crashes on macOS 10.13 HOT 18
- munkiimport and munkilib/pkgutils.py crash with packages containing .dist file HOT 13
- Preinstall_alerts not being shown for updated software HOT 3
- Placment of the back button in Managed Software Centre HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from munki.