iemejia / catho

A file catalog utility inspired by the awesome Robert Vasicek's Cathy project. Or my excuse to hack something that I really need.
GNU Lesser General Public License v3.0
6 stars 1 forks source link

Implement search of find option #7

Closed iemejia closed 11 years ago

iemejia commented 11 years ago

maybe find is a a better alias for this, it should accept regular expressions, and it searches for filename. what will be the sintax for other criterias e.g. date or filesize ?

iemejia commented 11 years ago

Some ideas: catho find regexp catho find --time > date catho find --size == num catho find --size > num

rgamez commented 11 years ago

The regex option on sqlite is provided through an extension, for example: https://github.com/oojah/sqlite3-pcre https://github.com/eatnumber1/sqlite-regexp

But there is an alternative, using the re module:

http://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.create_function

iemejia commented 11 years ago

doesn't sql 'like' cover this ? isn't it too slow to make the regex in python (even if it's mandatory) ? and finally, and more important, can you return maybe a list of [(catalog,[matches])] or something like that, so that the result shows aditionally in which catalog are the files.

rgamez commented 11 years ago

Of course it is a overhead, but LIKE it is not an equivalent as having regular expressions, you can only match one or one_ormore characters with and %, if you are worried about speed we could use simple match via LIKE '%pattern%' and add an extra keyword for matching via regex.

iemejia commented 11 years ago

No, I think the regex is the price to pay for the flexibility.

On Thu, Feb 28, 2013 at 7:05 PM, rgamez notifications@github.com wrote:

Of course it is a overhead, but LIKE it is not an equivalent as having regular expressions, you only can match one or one_ormore characters with and %, if you are worried about speed we could use simple match via LIKE '%pattern%' and add an extra keyword for matching via regex.

— Reply to this email directly or view it on GitHubhttps://github.com/iemejia/catho/issues/7#issuecomment-14247427 .

iemejia commented 11 years ago

what about the other query types (dates, filesize, etc) ? do you have any idea about how to define them in a possible general way ?

rgamez commented 11 years ago

Not really sure about the best option, I would like something such:

catho find [field] == value catho find [field1] == value1 and [field2] > value2 catho find [field1] == [field2]

But I don't remember any command line utility with a similar syntaxis, I think preventing issues with shell scripts and the notation for [optional] parameters

iemejia commented 11 years ago

I think that the default option of find must be to allow an string without * or % and just look for names that contain the string, it makes it more intuitive for the user. And the advanced options go with a different argument, like the regex one, or the sql one.

Also, I tried looking for 'Animal Collective' in our test catalog, but I didn't arrive to get the same answer that with cathy, can you check.

iemejia commented 11 years ago

I think there is some issue with the space in the name

rgamez commented 11 years ago

No, "Animal Collective" is not in the results because is matching just filenames not paths

iemejia commented 11 years ago

amazing fix, thanks :)