summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/fsobject/fsobject.py9
-rw-r--r--ranger/gui/widgets/statusbar.py7
2 files changed, 10 insertions, 6 deletions
diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py
index 9d942c65..f0adab67 100644
--- a/ranger/fsobject/fsobject.py
+++ b/ranger/fsobject/fsobject.py
@@ -35,8 +35,7 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 	last_used,
 	path,
 	permissions,
-	readlink,
-	stat) = (None,) * 12
+	stat) = (None,) * 11
 
 	(content_loaded,
 	force_load,
@@ -209,8 +208,10 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 				self.exists = False
 				self.runnable = False
 			if is_link:
-				self.realpath = realpath(path)
-				self.readlink = readlink(path)
+				try:
+					self.realpath = realpath(path)
+				except OSError:
+					pass  # it is impossible to get the link destination
 		else:
 			self.accessible = False
 
diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py
index 752bfd6b..3019930b 100644
--- a/ranger/gui/widgets/statusbar.py
+++ b/ranger/gui/widgets/statusbar.py
@@ -23,7 +23,7 @@ such as the space used by all the files in this directory.
 
 from pwd import getpwuid
 from grp import getgrgid
-from os import getuid
+from os import getuid, readlink
 from time import time, strftime, localtime
 
 from ranger.ext.human_readable import human_readable
@@ -164,7 +164,10 @@ class StatusBar(Widget):
 
 		if target.is_link:
 			how = target.exists and 'good' or 'bad'
-			dest = target.readlink if target.readlink is not None else '?'
+			try:
+				dest = readlink(target.path)
+			except:
+				dest = '?'
 			left.add(' -> ' + dest, 'link', how)
 		else:
 			if self.settings.display_size_in_status_bar and target.infostring:
ame.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# Sentiment Analyzer

## Overview

The Sentiment Analyzer is a JavaScript application designed to analyze the sentiment of web content. It utilizes a combination of dictionary-based sentiment analysis, emotion categorization, intensity analysis, web content extraction, and metadata parsing to provide a comprehensive emotional analysis of text from web pages.

### Key Features

- **Emotion Categorization**: Classifies emotions into various categories such as joy, sadness, anger, and more.
- **Intensity Analysis**: Measures the intensity of sentiments based on the context and usage of words.
- **Web Content Extraction**: Fetches and extracts meaningful content from web pages, ignoring irrelevant sections like headers and footers.
- **Metadata Parsing**: Extracts useful metadata such as titles, authors, and publication dates from web pages.

## Installation

To install dependencies, run:

```bash
bun install
```

## Usage

To run the sentiment analyzer, use the following command:

```bash
bun run app.js <url>
```

You can also analyze multiple URLs at once:

```bash
bun run app.js <url1> <url2> <url3>
```

### Example

```bash
bun run app.js https://example.com/blog-post
```

### Help

To display help information, use:

```bash
bun run app.js --help
```

## Building a Static Binary

Bun allows you to build your application as a static binary, which can be distributed and run without requiring a separate runtime environment. To build the Sentiment Analyzer as a binary, follow these steps:

1. **Build the Binary**: Run the following command in your terminal:

   ```bash
   bun build app.js --outdir ./bin --target node
   ```

   This command compiles your application into a single binary executable for Node.js and places it in the `./bin` directory.

2. **Run the Binary**: After building, you can run the binary directly:

   ```bash
   ./bin/app.js <url>
   ```

   Or for multiple URLs:

   ```bash
   ./bin/app.js <url1> <url2> <url3>
   ```

### Example

```bash
./bin/app.js https://example.com/blog-post
```

## Extending the Program

The Sentiment Analyzer is designed to be extensible. Here are some ways you can enhance its functionality:

1. **Add More Dictionaries**: You can extend the positive and negative word dictionaries by adding more words or phrases relevant to specific contexts or industries.

2. **Enhance Emotion Categories**: Modify the `emotionCategories` object in `app.js` to include additional emotions or synonyms that are relevant to your analysis needs.

3. **Implement Machine Learning**: Consider integrating machine learning models for more advanced sentiment analysis that can learn from context and improve over time.

4. **Support for Multiple Languages**: Extend the program to support sentiment analysis in different languages by adding language-specific dictionaries and rules.

5. **Dynamic Content Handling**: Improve the content extraction logic to handle dynamic web pages (Single Page Applications) that load content asynchronously.

6. **Batch Processing**: Implement functionality to read URLs from a file and process them in batches, which can be useful for analyzing large datasets.

7. **Output Formatting Options**: Add options to format the output in different ways (e.g., JSON, CSV) for easier integration with other tools or systems.

## Contributing

Contributions are welcome! If you have suggestions for improvements or new features, feel free to open an issue or submit a pull request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

This project was created using `bun init` in bun v1.1.29. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.